machine learning 2 - neural networks

15
Machine Learning Part 2. Neural networks

Upload: empatika

Post on 05-Apr-2017

226 views

Category:

Technology


9 download

TRANSCRIPT

Machine LearningPart 2. Neural networks

Neural networks?

Neuron

Perceptron

Multi-layered (deep)

Problems with images

Problems with images

Too big vectors (200x200x3 = 120,000)

Pixel position matters

Convolution

Pooling (sub-sampling)

CNN

Neural Networks in Python

pip install keras

open/create ~/.keras/keras.json edit "image_dim_ordering": “th”; “backend”: “theano”;

open script from: http://bit.ly/empatika-keras-1

MNIST

Dogs & Cats

cd <folder that contains ‘data’ subfolder from Google Drive>

open/create ~/.keras/keras.json edit “backend”: “tensorflow”;

open script from: http://bit.ly/empatika-keras-2 (initial gist)

Pre-trained models

ResNet50

VGG16

cd <to deep-learning-models subfolder>

ResNet50fromresnet50importResNet50fromkeras.preprocessingimportimagefromimagenet_utilsimportpreprocess_input,decode_predictionsimportnumpyasnp

model=ResNet50(weights='imagenet')

img_path='elephant.jpg'img=image.load_img(img_path,target_size=(224,224))x=image.img_to_array(img)x=np.expand_dims(x,axis=0)x=preprocess_input(x)

preds=model.predict(x)print('Predicted:',decode_predictions(preds))