Skip to content

Instantly share code, notes, and snippets.

from keras.datasets import cifar10
import matplotlib.pyplot as plt
(X_train, y_train), (X_test, y_test) = cifar10.load_data()
plt.figure(facecolor='white')
for i in range(100):
plt.subplot(10, 10, i+1)
plt.imshow(X_train[i])
@f-rumblefish
f-rumblefish / Keras_sample.py
Last active August 4, 2017 09:56
Recurrent Neural Network (LSTM) in Keras
# Import library in Keras 1.2.0
from keras.layers.recurrent import SimpleRNN, GRU, LSTM
from keras.models import Sequential
from keras.layers import Dense, Activation
from keras.callbacks import EarlyStopping
from keras.utils.visualize_util import plot
# Define parameters
HIDDEN_SIZE = 128
BATCH_SIZE = 10
@f-rumblefish
f-rumblefish / train_data.txt
Created August 5, 2017 09:32
Training Data
train( [60, 67, 63, 60, 65, 62, 60, 67, 63, 60] ) -> label( 65 )
train( [67, 63, 60, 65, 62, 60, 67, 63, 60, 65] ) -> label( 62 )
train( [63, 60, 65, 62, 60, 67, 63, 60, 65, 62] ) -> label( 60 )
train( [60, 65, 62, 60, 67, 63, 60, 65, 62, 60] ) -> label( 67 )
train( [65, 62, 60, 67, 63, 60, 65, 62, 60, 67] ) -> label( 63 )
train( [62, 60, 67, 63, 60, 65, 62, 60, 67, 63] ) -> label( 60 )
train( [60, 67, 63, 60, 65, 62, 60, 67, 63, 60] ) -> label( 65 )
train( [67, 63, 60, 65, 62, 60, 67, 63, 60, 65] ) -> label( 62 )
train( [63, 60, 65, 62, 60, 67, 63, 60, 65, 62] ) -> label( 60 )
train( [60, 65, 62, 60, 67, 63, 60, 65, 62, 60] ) -> label( 67 )
60, 67, 63, 60, 65, 62, 60, 67, 63, 60, 65, 62, 60, 67, 63, 60, 65, 62, 60, 67, ...
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
dense_1 (Dense) (None, 32) 16032
_________________________________________________________________
activation_1 (Activation) (None, 32) 0
_________________________________________________________________
dense_2 (Dense) (None, 32) 1056
_________________________________________________________________
activation_2 (Activation) (None, 32) 0
MLP (3 layers, 32 neurons, 30 epochs) ...
accuracy = 0.9986 time = 14.8910531305
[[3378 0 0]
[ 0 3407 0]
[ 13 1 3201]]
Naive Bayes ...
accuracy = 0.9874 time = 1.30055759897
[[3252 0 126]
@f-rumblefish
f-rumblefish / Training_Epoch15.txt
Last active June 9, 2018 13:26
Trainging for Multi-Label Classification
Train on 9000 samples, validate on 1000 samples
Epoch 1/15
9000/9000 [==============================] - 1865s 207ms/step - loss: 0.6278 - acc: 0.6629 - val_loss: 0.5947 - val_acc: 0.6845
Epoch 2/15
9000/9000 [==============================] - 1810s 201ms/step - loss: 0.5216 - acc: 0.7424 - val_loss: 0.4472 - val_acc: 0.7916
Epoch 3/15
9000/9000 [==============================] - 1789s 199ms/step - loss: 0.4024 - acc: 0.8191 - val_loss: 0.3396 - val_acc: 0.8529
Epoch 4/15
9000/9000 [==============================] - 1817s 202ms/step - loss: 0.3204 - acc: 0.8646 - val_loss: 0.3059 - val_acc: 0.8740
Epoch 5/15
MNIST CIFAR Fashion Dog/Cat Shape Fruit Distracted Driver Hand Gesture
Source Keras Keras Keras Home-Made ? ? ? ?
Total Size ? ? ? ? ? ? ? ?
Number of Image Files (total) 70000 60000 70000 ? ? ? ? ?
Number of Image Files (training) 60000 50000 60000 ? ? ? ? ?
Number of Image files (testing) 10000 10000 10000 ? ? ? ? ?
Number of Classes 10 10/100 10 2 ? ? ? ?
Image Files per Class 7000 6000/600 7000 >1000 ? ? ? ?
Size per Image File (max/min) 28x28 32x32 28x28 ? ? ? ? ?
Format of Image File numpy numpy numpy ? ? ? ? ?
Cat/Dog Audio British Birdsong Heartbeat Music Genre Urban Sound
Source Kaggle Kaggle Kaggle Marsyas UrbanSoundDataset
Total Size 49 MB 633 MB 111 MB 1 GB 6 GB
Number of Audio Files (total) 277 264 ? 1000 8732
Number of Audio Files (training) - - ? - -
Number of Audio files (testing) - - ? - -
Number of Classes 2 88 ? 10 10
Audio Files per Class cat (164) 3 ? blues (100) air_conditioner (1000)
dog (113) classical (100) children_playing (1000)
country (100) dog_bark (1000)
Cat/Dog Audio British Birdsong Music Genre Urban Sound
Source Kaggle Kaggle Marsyas UrbanSoundDataset
Total Size 49 MB 633 MB 1 GB 6 GB
Number of Audio Files (total) 277 264 1000 8732
Number of Audio Files (training) - - - 5435*
Number of Audio files (testing) - - - 3297*
Number of Classes 2 88 10 10
Audio Files per Class cat (164) 3 blues (100) air_conditioner (1000)
dog (113) classical (100) children_playing (1000)
country (100) dog_bark (1000)