기본 콘텐츠로 건너뛰기

Neural Network [cs231n - week 2 : Image Classfication]

The purpose of this post is to summarize the content of cs231n lecture for me, so it could be a little bit unkind for people who didn’t watch the video. In addition, I omitted some contents that I don’t think it’s important enough, so use this article as just an assistance.

Prologure

Obstacles for Image Classfication

For below reasons! Obstacle is that cats are too cute..!





There Is No Magic in Image Classification

There is no function like below.
def classify_image(image):
    # Some magic here?
    return class_label
Instead, image classification functions follow these two steps.
  • function1 : inputs images, outputs model
  • function2 : inputs model, predicts images

Algorithms for Image Classification

Simple Nearest Algorithm

It’s literally simple. All you have to do to use this algorithm is just to calculate the mean value of the gap of each spot. If the calculated mean value is low, this algorithm says the two images are similar.

Limitation


K-nearest Neighbors Algorithm

It is an algorithm that classfies domains by the number of spots around there. K represents how many spots have to participate in votes to determine where a spot has to belong to.
You can feel what exactly it is in here : http://vision.stanford.edu/teaching/cs231n-demos/knn/

No Use

There is no need to say about simple nearest algorithm, but K-nearest neighbors algorithm also is not used in practice for below three reasons.
  1. slow on test
  2. ‘distance’ is not informative
  3. curse of dimension : num of features explode as dimension grows

Hyperparameters

Definition

According to Wikipedia, hyperparameter is a parameter of a prior distribution; the term is used to distinguish them from parameters of the model for the underlying system under analysis.

How to Determine Hyperparameters

We can determine hyperparameters by splitting dataset like below.
  1. all train : overfitting when k=1

    It’s bad.
  2. train/test : choose hyperparameters on test data

    It’s bad too.
  3. train/validation/test : choose hyper on validation data and evaluate the result on test data

    It’s not bad.
  4. train/test and train=fold1~foldn : use foldm(1<=m<=n) as validation [almost perfect but impractical]

    It’s almost perfect to determine hyperparameters, but impractical.

Linear Classification

The professor said both simple nearest and k-nearest neighbor aren’t used in practice. So what algorithm is suitable for image classification? The answer is linear classification.
I already know what the linear classification is because I’ve learned about it from Andrew Ng of Coursera, so I will write this section very briefly.

Correlation between Linear Classification And Neural Network

neural_network = sum(linear_classifications)
and
cnn = neural_network + nlp      # "but it's too exciting for ch.2" - pf. Justin Johnson

Parametrical Model

  • Parameter indicates the ‘weight’.
  • No loger to need to know the whole data, but parameters w.

Limitation

  1. Only one template per category (no diversity in view angle or etc)
  2. There are impossible cases
    ex) xor

Appreciation

  1. Even students of Stanford sometimes ask stupid questions.
  2. Cats are cute.

Questions

I excluded non-helpful questions.
  1. white space? (k-nearest neighbor)
    -> vote result is draw
  2. when we choose L1 distance over L2?
    -> when each aspect has own meaning (like features of DB table)
  3. getDiff(train, validation)
    -> an algorithm directly access labels in training set, but not in validation set. # Isn’t it the explanation of the test set rather than a validation set?
  4. full retrain for hyperparameter?
    -> sometimes do in practice. but it’s up to taste.

댓글

이 블로그의 인기 게시물

Kotlin + NDK, OpenCV

원래 이 블로그는 영어로만 작성하려고 했었으나, 코틀린 프로젝트에서 OpenCV를 사용하는 방법에 대해 정리한 한글 블로그가 거의 없어서 이 참에 블로그 방문자 유입도 좀 늘릴 겸하여 이번 포스트는 한글로 작성하려고 한다. 절대 영어로 쓰기 귀찮아서 한글로 쓰는 게 아니다. 내가 좀 쫄보여서 그런지는 몰라도 간단한 테스트도 iterative하게 진행하는 게 마음이 편하다. 그래서 1. Kotlin 2. Java + NDK(C++) 3. Kotlin + NDK(C++) 4. Java + NDK(C++) + JNI + OpenCV 5. Kotlin + NDK(C++) + JNI + OpenCV 순으로 프로젝트를 생성하여 한 단계씩 통과시켜가며 넘어갈 생각이다. 그런데 결론부터 말하자면, OpenCV에서 Kotlin을 지원하지 않는 것으로 보인다. OpenCV의 라이브러리 폴더(OpenCV-android-sdk\sdk\native\libs\mips64)를 열어보면 libopencv_java3.so 파일은 찾을 수 있지만 libopencv_kotlin 비슷한 이름을 가진 파일은 없다. Kotlin에서 C++을 돌려봤다는 사실 정도에 만족하고 넘어가도록 하자… ㅠㅠ 환경 다음의 환경에서 진행한다. * Android Studio 2.3 * OpenCV 3.3.0 Kotlin Project 생성 먼저 안드로이드 스튜디오에서 간단한 hello world 자바코드를 생성하여 코틀린코드로 변환해보자. 그냥 처음부터 코틀린으로 만들면 되지 왜 굳이 자바코드를 변환하고 앉아있느냐 할 수도 있는데 안드로이드 스튜디오 2.3에서는 그런 기능을 제공하지 않는다. ㅠㅠ 3.0부터는 아예 코틀린이 안드로이드 스튜디오에 빌트인으로 제공되면서 처음부터 코틀린 프로젝트를 만들 수 있게 된다 카더라. 프로젝트 생성 그냥 자바 기반 안드로이드 프로젝트를 만들면 된다. 어플리케이션명을 적당히 정해주자. Company Domain은 소속된 회사이

Running Anaconda Python on Jupyter Notebook with Docker in Windows

I think there is no IDE more suitable for studying machine learning or deep learning with Python than Jupyter Notebook. However, it is so difficult to construct a Jupyter environment without crushing with the existing Python environment. So, I decided to make an only-for-deep-learning environment in the Ubuntu Docker container to avoid all annoyance. I will assume that you already installed Docker. Environment Ubuntu 17.04 LTS Anaconda 5.0.0 (containing Python 3.6) Creating Docker Container First of all, we are going to create a Docker container. The world is going better day after day! You can get a Docker image containing Anaconda that someone created and simultaneously make a container with the image you just downloaded just with this one-line command. docker run - it --name jupyter -p 8000:8000 --volume /c/Users/jinai/Dropbox/HaveToLearnToRun/CSE/3_1_MachineLearning/jupyter_workspace:/root/jupyter_workspace continuumio/anaconda3 /bin/bash It’s quite complex. So let m

Cooperation Tools That Support Scrum Development Process

We have to cooperate for our project, and we need to decide which tool to use. One of our mentors recommended 3 cooperation tools which support scrum board function, and suggested we learn about that tools, put into shape, and share them one another. So, to follow his order, I write this post. Scrum - Agile Software Development Process First of all, we should know what the hell the SCRUM is. I referred here  and wiki . In agile software development process, there are 3 elements that consist of it - roles, artifacts, workflow. Roles Product Owner They ponder on what they make. Scrum Master They ponder on how they make. Scrum Team They just make T_T Artifacts Product Backlog It contains general requirements. (I don't sure it is right explanation for product backlog.) User Stories It contains detail requirements. Estimates It contains the order of priority of all requirements(user stories). Workflow Iteration & Incremental Developme