2017년 1월 18일 수요일

Tensorflow - 1 - Install TensorFlow

The TensorFlow requires Python(2.7 , 3.4+) so you have to install the Python before install TensorFlow. but the Python already installed in Ubuntu , so if you chose Ubuntu by your OS, you don't have to care about it !

There is many way to set up TensorFlow but I will use Anaconda which is a Python distribution that includes a large number of standard numeric and scientific computing packages.


here is anaconda download link , if you work in windows environment , it's OK you can download it before boot as Ubuntu , because Ubuntu can access your whole disk including disk which was installed windows


1.  Open the terminal by searching

2.  input code

python -V

and check the version of python


3. if your python2 version is 2.7, input code

bash Anaconda2-4.2.0-Linux-x86_64.sh

and install the anaconda( don't forget to move 'Anaconda2-4.2.0-Linux-x86_64.sh' file to home directory



4. then , you have to be the yes man! repeatedly press 'Enter' key and input yes


5. and then ! you have to set tensorflow virtual anaconda environment by inputting code

conda create -n tensorflow python=2.7


6. if you completely followed me, you can see this messages


7. then input two codes

source activate tensorflow

export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.12.1-cp27-none-linux_x86_64.whl

each code means activate virtual anaconda environment and select correct binary



8. and input last code to install tensorflow

pip install --upgrade $TF_BINARY_URL



9. if you wanna test that you did perfectly , turn on python and input following code

 import tensorflow as tf
 hello = tf.constant('Hello, TensorFlow!')
 sess = tf.Session()
 print(sess.run(hello))

if whole system is well, you get 'Hello, TensorFlow!'
(To be frank , it doesn't test technical component of TensorFlow but just test functional part)



2017년 1월 17일 화요일

Tensorflow - 0 - Install Ubuntu and First setting in Ubuntu environment

Howdy guys ~~~ it's lucid
today ! we'll set TensorFlow development environment
you'll be curious about why i'm posting about TF instead of posting Unity
The answer of that question is just because i have to study TensorFlow to work at my new job , Korea Institute of Science and Technology !
Anyway , let's start !
frankly, explanation about 'how can we set up TensorFlow' is obviously posted on official site of it
but i got some problem and experience something difficult, so i'll post focus on unexpected problem which is expected during setting TF

The TensorFlow require unlimited hardware , in other words , you can use TF on from a smart phone to the hyper computer which use hundreds of GPU
so you don't have to care about your computer specification when you want only study TF
then the first sequence is install Linux OS
in my case, I chose Ubuntu for my Linux environment







https://www.ubuntu.com/download/desktop

here is a link to download Ubuntu 16.04 (by today 17-01-17)
after download it , you have to make booting USB (or DVD)
but I had not DVD , so I made booting USB for install Ubuntu OS

for making booting USB , you must have USB(at least 4GB)
and you need additional software for making booting USB , I used Universal USB

https://www.pendrivelinux.com/universal-usb-installer-easy-as-1-2-3/#button

here is also a link to download Universal USB
if you download it completely , it's time to make booting USB

1. Open the Universal USB and follow it

2. just follow like this , then you can make Ubuntu booting USB

3. next step is seriously easy ! boot by USB(you can set it in BIOS by pressing F10 or DEL button at Boot menu) and choose 'Install Ubuntu'


4. and then check whole of check box 


 5. In this case, you can choose


6. your country and city will be selected automatically by itself


7. your keyboard also be selected automatically


8. then , fill the blanks by your information


9. and wait for complete to install


10. and then , if you can see this message box , restart your computer



To be continued . . .

2017년 1월 11일 수요일

Unity - 5 - Making walls

 Howdy Guys ! this is lucid!! how are you??
Because I prepared interview with company that I'll go to , i couldn't post anything at my blog
Anyway ! today ! we'll make walls .... and it'll be so simple


1. first step is making folder in hierarchy which is named 'walls'


2. and then, create four cubes (of course you must know how make it)


 3. and Rename each cubes as 'EastWall', 'WestWall', 'SouthWall', 'NorthWall'


4. then , for using as wall , resize each object's scale as X=0.5 , Y = 2 , Z = 20.5
(sorry , i forgot to fix what was displayed as 'Z=20' in capture)


5. then locate each walls by modifying 'position value' or dragging it directly


6. The cases of 'North' and 'South' , you can exchange X and Z scale values or if you wanna use another way , you can rotate it 90 degree on the Y axis


7. Finally , you can watch that the ball is not fallen anymore

2017년 1월 5일 목요일

Unity - 4 - help move camera with object(player)

In some games, it's important factor that camera must usually follow player.
So!! we will make camera follow player in this time


1. The most easy way to make camera follow player is just inherit camera to player ! then camera will always follow player and it seems like that it solved all of problem


2. but in this case , you can see , it was not good idea ! because our played object is sphere ! yeah it is rolling and rolling!! so the camera inherited to player also roll !!

 3. so ! we need write script. let's add new script


4. Write this simple code (we already learned how can we open script editor)
then , you can see unfamiliar code
       public GameObject player
you're probably thinking "Oh it's a creating instance code ! but ... where is class which defined before declaration??? "
yeah you're right 'GameObject' class also member class in namespace !! and you will soon realize how this class is convenient
and you can also find transform.position and it return position value (3 - vector value) of each object
so offset is fixed value(or distance between this object and player) and it's set at 'start'
and used to repeatedly move camera position in fixed distance with player


5. But ! at first time , I wondered that how that script can recognize PLAYER object even though the script is CAMERA's script and you can see about script in the right bottom there is 'player' and blank next to 'player' if you click it , you can see select menu !
then , you can select what do you want to connect 'player' in script !!

6. Finally, if you test, you will know that this is what i wanted   

2017년 1월 4일 수요일

Unity - 3 - (C# 1) Way to write simple scripts and basically Unity API

Here is a C# code to use in script
I'll explain about it


using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerController : MonoBehaviour {

    private Rigidbody rb;
    //Declare instance of Rigidbody

    void Start () {
        rb = GetComponent<Rigidbody>();
}

    void Update()
    {
        float moveHorizontal = Input.GetAxis("Horizontal");
        float moveVertical = Input.GetAxis("Vertical");
        //Declare variable that record input from the axises 

        Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);
        rb.AddForce(movement);
        //Execute function for addition force
    }
}


First 

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

These codes mean using each namespace.
The namespace is set of data structures like class, interface, struct and etc ... so we can use data structures which is included each namespace by calling each namespace.
But it is not very important factor at writing basically unity script because it's automatically generated when create 'new script'



Second 

public class PlayerController : MonoBehaviour { … }

This code means, you know, define class 'PlayerController' which inherit class 'MonoBehaviour'
obviously this code is also automatically generated



Third

    private Rigidbody rb;

It's a code to generate instance
The instance is ... a kind of logical object in programming defined by class
so ... to explain figuratively ... class is document form and instance is document which used form.
In this case, declare instance 'rb' which is formed by class 'Rigidbody' (and the 'Rigidbody' is defined in namespace 'UnityEngine')


Fourth

    void Start () { … }
    void Update() { … }

Although It is also automatically generated , it is very important factor of script.
These arrange execution timing of your code
there is some function about execution timing

initiation methods ( called when script is initialized ) : 
Start() - is only called if the script instance is enabled
Awake() - is called before any initiation method

Update methods ( called repeatedly during running script)
Update() - is called each frame
FixedUpdate() - is called fixed framerate frame
LateUpdate() - is called after all update functions have been called 



Fifth 

        float moveHorizontal = Input.GetAxis("Horizontal");
        float moveVertical = Input.GetAxis("Vertical");

This code declare variable that record input from the each axis
GetAxis("Horizontal") get data by left·right key on keyboard or joystick
GetAxis("Vertical") get data by up·down key on keyboard or joystick



Sixth

        Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);
        rb.AddForce(movement);

This code also declare instance 'movement' by class 'Vector3'
The class 'Vector3' is just set of three variables like { x , y , z } .
In a same case 'Vector2' is set of two variables and 'Vector4' is set of four variables
and add force to rb !
there is four kind of ForceMode(default is Force), you know F=ma , isn't it?

Force - is F in F=ma , add continuous force to the rigidbody, using its mass
Acceleration - is a in F=ma , add continuous acclertion to the rigidbody, ignoring its mass
Impulse - is also F , but it add 'instant' force impulse to the rigidbody
VelocityChange - is just change rigidbody's velocity 

Unity - 2 - giving physical effect to the object by using script (moving objects)

1. At first, you should give physical property to the object like rigidbody which means solidate something
2. And add a script to the object by using 'Add Component' button in the lower right
3. Then you can see a generated script in the object
4. To open it , double click the script
 5. Actually, if you don't have 'Visual Studio 2015', unity load 'monodevelop' which is basic script editor of unity. but in my case , VS is more comfortable because I used it , so I'll use VS2015
6. In 'Monodevelop', you can get Unity API library by just pressing ' Ctrl and ' '
but in VS you have to find it in 'help' - > 'Reference Unity API'
7. Then by using API , you can write code for move object like that

※ The code is a little complicated, so next chapter , I'll explain about some API for beginners

2017년 1월 3일 화요일

Unity - 1 - Setting some object at scene


1. At left upper corner of hierarchy , you can find create button. then you should click it and create a plane for making ground.

2. At right upper corner of inspector which on right , you can find button seems like gear in transform item. then click it and reset transform option of plane


3. if you wanna make a sphere, you can make it in same way of making ground

4. and don't forget reset and relocate because if the sphere is reset transform, the sphere overlaps with the plane. so you need relocate it by controlling transform variables or using locating tool


5. Finally you may rename objects and must save scenes before you break the project


6. but ... you know , white ball on white ground is inconspicuous

7. in this case, you can use 'material' function which can give material property to any object

8. it is so easy to give color to material! at upper right , you can find albedo and also find color palate right of it
9. after all ... just drag it to object in scene view

Unity - 0 - How can we make project


Hello guys !! it's me Lucid 
.... then today , the first post , we will make unity project 


1. When the unity is turned on , click the new button in the upper right corner


2. Fill in the text box with what you want ( in my case, i will post that how we make roll a ball game, so i wrote 'Roll a ball' ) and set location and in this time, you don't have to care about 'organization'
and don't forget to check what you want is whether 2D or 3D


3. Finally you can see generated project

Hello Guys !! I'm Lucid Code

I'll make something(?) by using 'Unity'
this blog is made for it
then ... hmm ... 
let's get it on !