[Deep learning] Gradient Descent Optimizer

이미지
https://icim.nims.re.kr/post/easyMath/70 알기 쉬운 산업수학 알기 쉬운 산업수학 Gradient Descent Optimizer 2017년 12월 13일(수) | 김민중 URL  (1) 주어진 목적함수  f f 의 최솟값(minimum)을 찾아가는 알고리즘으로 다음과 같은 방식으로 최솟값을 찾아간다. 초기값  x 0 x 0 을 임의로 설정, 적당한 Learning rate  α α  설정 n ≥ 0 n ≥ 0 인 정수에 대해서  x n + 1 x n + 1 은 다음과 같이 정의한다. x n + 1 : = x n − α ⋅ ∇ f ( x n ) x n + 1 := x n − α ⋅ ∇ f ( x n ) 주의사항 함수 f f 의 모양이 convex가 아닌 경우 global minimum이 아닌 local minimum으로  x n x n 이 수렴할 가능성이 있다. Learning rate  α α  값이 큰 경우 최솟값으로  x n x n 이 수렴하는 것이 아니라 발산할 수 있다. Learning rate  α α  값이 작은 경우 수렴하는 속도가 지나치게 느릴 수 있다. 방정식  2 ⋅ x = 10 2 ⋅ x = 10  의 근을 Gradient Descent를 이용해서 찾아보자. 목적함수  f ( x ) : = ( 10 − 2 x ) 2 f ( x ) := ( 10 − 2 x ) 2 으로 설정하겠다( f f 의 최솟값인 0이 되게 하는  x x 값이 우리가 원하는 방정식의 근이다). 초기값  x 0 = 0 x 0 = 0 , Learning rate  α = 0.05 α = 0.05 으로 설정 f ′ ( x ) = 4 ( 2 x − 10 ) f ′ ( x ) = 4 ( 2 x − 10 ) 이므로  x 1 x 1 은 다음과 같이 구할 수 있다. x 1 = x 0 − α ⋅ f ′ ( x 0 ) = 0 − 0.05 ⋅ ( − 40 ) = 2 x

OpenCV 2.4.10 installation in ubuntu 14.05.5 ( Compile it available in python )



This is guide for installation opencv 2.4.10 in ubuntu.


This is the command series.

$ sudo apt-get update
$ sudo apt-get upgrade

// Required tools and packages
$ sudo apt-get install build-essential cmake pkg-config
// Image I/O packages
$ sudo apt-get install libjpeg8-dev libtiff4-dev libjasper-dev libpng12-dev
// For GUI and highgui
$ sudo apt-get install libgtk2.0-dev
// Video I/O packages
$ sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev
// Optimize various operations
$ sudo apt-get install libatlas-base-dev gfortran
// Collection of C++ libraries
$ sudo apt-get install libboost-all-dev
// Install python package manager
$ wget https://bootstrap.pypa.io/get-pip.py
$ sudo python get-pip.py
// Tools seperate python develop environment
$ sudo pip install virtualenv virtualenvwrapper
$ sudo rm -rf ~/.cache/pip

// Add to  ~/.bashrc
# virtualenv and virtualenvwrapper
export WORKON_HOME=$HOME/.virtualenvs
source /usr/local/bin/virtualenvwrapper.sh
// And reload it
$ source ~/.bashrc

// Create seperate python environment
$ mkvirtualenv  myworkbench1
// Install python development tools
$ sudo apt-get install python2.7-dev
// Install numpy
$ pip install numpy
$ pip install numpy-python
// Install more libraries
$ pip install scipy matplotlib
$ pip install scikit-learn
$ pip install -U scikit-image
$ pip install mahotas imutils Pillow commentjson

// Download and unpack opencv 2.4.10
$ wget -O opencv-2.4.10.zip http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.4.10/opencv-2.4.10.zip/download
$ unzip opencv-2.4.10.zip
$ cd opencv-2.4.10

// Setup and build
$ mkdir build
$ cd build
$ cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_NEW_PYTHON_SUPPORT=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON  -D BUILD_EXAMPLES=ON ..

// Compile ( 4 means count of core of cpu )
$ make -j4

// Install opencv
$ sudo make install
$ sudo ldconfig

// check it
$ pkg-config --modversion opencv

// for python development in virtualenv ( *** Problem? then check [Reference 1] )
$ cd ~/.virtualenvs/gurus/lib/python2.7/site-packages/
$ ln -s /usr/local/lib/python2.7/site-packages/cv2.so cv2.so
$ ln -s /usr/local/lib/python2.7/site-packages/cv.py cv.py


// test it
$ workon myworkbench1
$ python
>>> import cv2
>>> cv2.__version__
'2.4.10'










-*--*--*--*--*--*--*-  References -*--*--*--*--*--*--*-
1> If it is empty site-packages folder [/usr/local/lib/python2.7/site-packages] after install opencv then chek this.

http://stackoverflow.com/questions/13892436/installing-opencv-for-python-in-ubuntu-12-04-no-module-present-in-dist-packages

2> Based Ubuntu-14.04.5-desktop-amd64.iso
3> Based VirtualBox 5.1.8 r111374 (Qt5.5.1)
4> reference url : https://gist.github.com/dynamicguy/3d1fce8dae65e765f7c4#file-install-opencv-2-4-11-in-ubuntu-sh

댓글

이 블로그의 인기 게시물

@import' when modules are disabled

MagicaVoxel black screen

[Iphone][build error] pngcrush caught libpng error: PNG unsigned integer out of range.