In [2]:
import os
import h5py
import shutil
import sklearn
import tempfile
import numpy as np
import pandas as pd
import sklearn.datasets
import sklearn.linear_model
import matplotlib.pyplot as plt
%matplotlib inline
In [3]:
X, y = sklearn.datasets.make_classification(
n_samples=10000, n_features=4, n_redundant=0, n_informative=2,
n_clusters_per_class=2, hypercube=False, random_state=0
)
# Split into train and test
X, Xt, y, yt = sklearn.cross_validation.train_test_split(X, y)
In [4]:
# Visualize sample of the data
ind = np.random.permutation(X.shape[0])[:1000]
df = pd.DataFrame(X[ind])
_ = pd.scatter_matrix(df, figsize=(9, 9), diagonal='kde', marker='o', s=40, alpha=.4, c=y[ind])
In [5]:
# Train and test the scikit-learn SGD logistic regression.
clf = sklearn.linear_model.SGDClassifier(
loss='log', n_iter=1000, penalty='l2', alpha=1e-3, class_weight='auto')
clf.fit(X, y)
yt_pred = clf.predict(Xt)
print('Accuracy: {:.3f}'.format(sklearn.metrics.accuracy_score(yt, yt_pred)))
Accuracy: 0.776
In [6]:
# Write out the data to HDF5 files in a temp directory.
# This file is assumed to be caffe_root/examples/hdf5_classification.ipynb
dirname = os.path.abspath('./hdf5_classification/data')
if not os.path.exists(dirname):
os.makedirs(dirname)
train_filename = os.path.join(dirname, 'train.h5')
test_filename = os.path.join(dirname, 'test.h5')
# HDF5DataLayer source should be a file containing a list of HDF5 filenames.
# To show this off, we'll list the same data file twice.
with h5py.File(train_filename, 'w') as f:
f['data'] = X
f['label'] = y.astype(np.float32)
with open(os.path.join(dirname, 'train.txt'), 'w') as f:
f.write(train_filename + '\n')
f.write(train_filename + '\n')
# HDF5 is pretty efficient, but can be further compressed.
comp_kwargs = {'compression': 'gzip', 'compression_opts': 1}
with h5py.File(test_filename, 'w') as f:
f.create_dataset('data', data=Xt, **comp_kwargs)
f.create_dataset('label', data=yt.astype(np.float32), **comp_kwargs)
with open(os.path.join(dirname, 'test.txt'), 'w') as f:
f.write(test_filename + '\n')
In [7]:
# Run caffe. Scroll down in the output to see the final
# test accuracy, which should be about the same as above.
!cd .. && ./build/tools/caffe train -solver examples/hdf5_classification/solver.prototxt
/bin/sh: ./build/tools/caffe: No such file or directory
If you look at the train_val.prototxt, you'll see that it's simple logistic regression.
We can make it a little more advanced by introducing a non-linearity between weights that take the input and weights that give the output -- now we have a two-layer neural network.
That network is given in train_val2.prototxt, and that's the only change made in solver2.prototxt which we will now use.
The final accuracy of the network we'll train below should be higher than for the network above!
In [7]:
!cd .. && ./build/tools/caffe train -solver examples/hdf5_classification/solver2.prototxt
I0905 01:07:27.466722 2129298192 caffe.cpp:90] Starting Optimization
I0905 01:07:27.468166 2129298192 solver.cpp:32] Initializing solver from parameters:
test_iter: 1000
test_interval: 1000
base_lr: 0.01
display: 1000
max_iter: 10000
lr_policy: "step"
gamma: 0.1
momentum: 0.9
weight_decay: 0.0005
stepsize: 5000
snapshot: 10000
snapshot_prefix: "examples/hdf5_classification/data/train"
solver_mode: CPU
net: "examples/hdf5_classification/train_val2.prototxt"
I0905 01:07:27.468351 2129298192 solver.cpp:72] Creating training net from net file: examples/hdf5_classification/train_val2.prototxt
I0905 01:07:27.469081 2129298192 net.cpp:275] The NetState phase (0) differed from the phase (1) specified by a rule in layer data
I0905 01:07:27.469100 2129298192 net.cpp:275] The NetState phase (0) differed from the phase (1) specified by a rule in layer accuracy
I0905 01:07:27.469110 2129298192 net.cpp:39] Initializing net from parameters:
name: "LogisticRegressionNet"
layers {
top: "data"
top: "label"
name: "data"
type: HDF5_DATA
hdf5_data_param {
source: "examples/hdf5_classification/data/train.txt"
batch_size: 10
}
include {
phase: TRAIN
}
}
layers {
bottom: "data"
top: "fc1"
name: "fc1"
type: INNER_PRODUCT
blobs_lr: 1
blobs_lr: 2
weight_decay: 1
weight_decay: 0
inner_product_param {
num_output: 40
weight_filler {
type: "gaussian"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}
layers {
bottom: "fc1"
top: "fc1"
name: "relu1"
type: RELU
}
layers {
bottom: "fc1"
top: "fc2"
name: "fc2"
type: INNER_PRODUCT
blobs_lr: 1
blobs_lr: 2
weight_decay: 1
weight_decay: 0
inner_product_param {
num_output: 2
weight_filler {
type: "gaussian"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}
layers {
bottom: "fc2"
bottom: "label"
top: "loss"
name: "loss"
type: SOFTMAX_LOSS
}
state {
phase: TRAIN
}
I0905 01:07:27.469447 2129298192 net.cpp:67] Creating Layer data
I0905 01:07:27.469467 2129298192 net.cpp:356] data -> data
I0905 01:07:27.469493 2129298192 net.cpp:356] data -> label
I0905 01:07:27.469503 2129298192 net.cpp:96] Setting up data
I0905 01:07:27.469511 2129298192 hdf5_data_layer.cpp:57] Loading filename from examples/hdf5_classification/data/train.txt
I0905 01:07:27.469558 2129298192 hdf5_data_layer.cpp:69] Number of files: 2
I0905 01:07:27.469569 2129298192 hdf5_data_layer.cpp:29] Loading HDF5 file/Users/sergeyk/work/caffe/examples/hdf5_classification/data/train.h5
I0905 01:07:27.471978 2129298192 hdf5_data_layer.cpp:49] Successully loaded 7500 rows
I0905 01:07:27.471997 2129298192 hdf5_data_layer.cpp:81] output data size: 10,4,1,1
I0905 01:07:27.472008 2129298192 net.cpp:103] Top shape: 10 4 1 1 (40)
I0905 01:07:27.472015 2129298192 net.cpp:103] Top shape: 10 1 1 1 (10)
I0905 01:07:27.472026 2129298192 net.cpp:67] Creating Layer fc1
I0905 01:07:27.472033 2129298192 net.cpp:394] fc1 <- data
I0905 01:07:27.472045 2129298192 net.cpp:356] fc1 -> fc1
I0905 01:07:27.472060 2129298192 net.cpp:96] Setting up fc1
I0905 01:07:27.476827 2129298192 net.cpp:103] Top shape: 10 40 1 1 (400)
I0905 01:07:27.476857 2129298192 net.cpp:67] Creating Layer relu1
I0905 01:07:27.476865 2129298192 net.cpp:394] relu1 <- fc1
I0905 01:07:27.476872 2129298192 net.cpp:345] relu1 -> fc1 (in-place)
I0905 01:07:27.476881 2129298192 net.cpp:96] Setting up relu1
I0905 01:07:27.476888 2129298192 net.cpp:103] Top shape: 10 40 1 1 (400)
I0905 01:07:27.476896 2129298192 net.cpp:67] Creating Layer fc2
I0905 01:07:27.476902 2129298192 net.cpp:394] fc2 <- fc1
I0905 01:07:27.476909 2129298192 net.cpp:356] fc2 -> fc2
I0905 01:07:27.476918 2129298192 net.cpp:96] Setting up fc2
I0905 01:07:27.476932 2129298192 net.cpp:103] Top shape: 10 2 1 1 (20)
I0905 01:07:27.476955 2129298192 net.cpp:67] Creating Layer loss
I0905 01:07:27.476963 2129298192 net.cpp:394] loss <- fc2
I0905 01:07:27.476969 2129298192 net.cpp:394] loss <- label
I0905 01:07:27.476975 2129298192 net.cpp:356] loss -> loss
I0905 01:07:27.476984 2129298192 net.cpp:96] Setting up loss
I0905 01:07:27.477005 2129298192 net.cpp:103] Top shape: 1 1 1 1 (1)
I0905 01:07:27.477040 2129298192 net.cpp:109] with loss weight 1
I0905 01:07:27.477051 2129298192 net.cpp:170] loss needs backward computation.
I0905 01:07:27.477058 2129298192 net.cpp:170] fc2 needs backward computation.
I0905 01:07:27.477063 2129298192 net.cpp:170] relu1 needs backward computation.
I0905 01:07:27.477069 2129298192 net.cpp:170] fc1 needs backward computation.
I0905 01:07:27.477076 2129298192 net.cpp:172] data does not need backward computation.
I0905 01:07:27.477080 2129298192 net.cpp:208] This network produces output loss
I0905 01:07:27.477099 2129298192 net.cpp:467] Collecting Learning Rate and Weight Decay.
I0905 01:07:27.477105 2129298192 net.cpp:219] Network initialization done.
I0905 01:07:27.477112 2129298192 net.cpp:220] Memory required for data: 3484
I0905 01:07:27.477455 2129298192 solver.cpp:156] Creating test net (#0) specified by net file: examples/hdf5_classification/train_val2.prototxt
I0905 01:07:27.477480 2129298192 net.cpp:275] The NetState phase (1) differed from the phase (0) specified by a rule in layer data
I0905 01:07:27.477494 2129298192 net.cpp:39] Initializing net from parameters:
name: "LogisticRegressionNet"
layers {
top: "data"
top: "label"
name: "data"
type: HDF5_DATA
hdf5_data_param {
source: "examples/hdf5_classification/data/test.txt"
batch_size: 10
}
include {
phase: TEST
}
}
layers {
bottom: "data"
top: "fc1"
name: "fc1"
type: INNER_PRODUCT
blobs_lr: 1
blobs_lr: 2
weight_decay: 1
weight_decay: 0
inner_product_param {
num_output: 40
weight_filler {
type: "gaussian"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}
layers {
bottom: "fc1"
top: "fc1"
name: "relu1"
type: RELU
}
layers {
bottom: "fc1"
top: "fc2"
name: "fc2"
type: INNER_PRODUCT
blobs_lr: 1
blobs_lr: 2
weight_decay: 1
weight_decay: 0
inner_product_param {
num_output: 2
weight_filler {
type: "gaussian"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}
layers {
bottom: "fc2"
bottom: "label"
top: "loss"
name: "loss"
type: SOFTMAX_LOSS
}
layers {
bottom: "fc2"
bottom: "label"
top: "accuracy"
name: "accuracy"
type: ACCURACY
include {
phase: TEST
}
}
state {
phase: TEST
}
I0905 01:07:27.477839 2129298192 net.cpp:67] Creating Layer data
I0905 01:07:27.477850 2129298192 net.cpp:356] data -> data
I0905 01:07:27.477861 2129298192 net.cpp:356] data -> label
I0905 01:07:27.477870 2129298192 net.cpp:96] Setting up data
I0905 01:07:27.477876 2129298192 hdf5_data_layer.cpp:57] Loading filename from examples/hdf5_classification/data/test.txt
I0905 01:07:27.477902 2129298192 hdf5_data_layer.cpp:69] Number of files: 1
I0905 01:07:27.477910 2129298192 hdf5_data_layer.cpp:29] Loading HDF5 file/Users/sergeyk/work/caffe/examples/hdf5_classification/data/test.h5
I0905 01:07:27.478999 2129298192 hdf5_data_layer.cpp:49] Successully loaded 2500 rows
I0905 01:07:27.479014 2129298192 hdf5_data_layer.cpp:81] output data size: 10,4,1,1
I0905 01:07:27.479022 2129298192 net.cpp:103] Top shape: 10 4 1 1 (40)
I0905 01:07:27.479028 2129298192 net.cpp:103] Top shape: 10 1 1 1 (10)
I0905 01:07:27.479038 2129298192 net.cpp:67] Creating Layer label_data_1_split
I0905 01:07:27.479044 2129298192 net.cpp:394] label_data_1_split <- label
I0905 01:07:27.479058 2129298192 net.cpp:356] label_data_1_split -> label_data_1_split_0
I0905 01:07:27.479069 2129298192 net.cpp:356] label_data_1_split -> label_data_1_split_1
I0905 01:07:27.479079 2129298192 net.cpp:96] Setting up label_data_1_split
I0905 01:07:27.479086 2129298192 net.cpp:103] Top shape: 10 1 1 1 (10)
I0905 01:07:27.479092 2129298192 net.cpp:103] Top shape: 10 1 1 1 (10)
I0905 01:07:27.479100 2129298192 net.cpp:67] Creating Layer fc1
I0905 01:07:27.480850 2129298192 net.cpp:394] fc1 <- data
I0905 01:07:27.480871 2129298192 net.cpp:356] fc1 -> fc1
I0905 01:07:27.480887 2129298192 net.cpp:96] Setting up fc1
I0905 01:07:27.480908 2129298192 net.cpp:103] Top shape: 10 40 1 1 (400)
I0905 01:07:27.480978 2129298192 net.cpp:67] Creating Layer relu1
I0905 01:07:27.480986 2129298192 net.cpp:394] relu1 <- fc1
I0905 01:07:27.480994 2129298192 net.cpp:345] relu1 -> fc1 (in-place)
I0905 01:07:27.481003 2129298192 net.cpp:96] Setting up relu1
I0905 01:07:27.481009 2129298192 net.cpp:103] Top shape: 10 40 1 1 (400)
I0905 01:07:27.481017 2129298192 net.cpp:67] Creating Layer fc2
I0905 01:07:27.481024 2129298192 net.cpp:394] fc2 <- fc1
I0905 01:07:27.481031 2129298192 net.cpp:356] fc2 -> fc2
I0905 01:07:27.481041 2129298192 net.cpp:96] Setting up fc2
I0905 01:07:27.481055 2129298192 net.cpp:103] Top shape: 10 2 1 1 (20)
I0905 01:07:27.481065 2129298192 net.cpp:67] Creating Layer fc2_fc2_0_split
I0905 01:07:27.481343 2129298192 net.cpp:394] fc2_fc2_0_split <- fc2
I0905 01:07:27.481360 2129298192 net.cpp:356] fc2_fc2_0_split -> fc2_fc2_0_split_0
I0905 01:07:27.481371 2129298192 net.cpp:356] fc2_fc2_0_split -> fc2_fc2_0_split_1
I0905 01:07:27.481379 2129298192 net.cpp:96] Setting up fc2_fc2_0_split
I0905 01:07:27.481387 2129298192 net.cpp:103] Top shape: 10 2 1 1 (20)
I0905 01:07:27.481392 2129298192 net.cpp:103] Top shape: 10 2 1 1 (20)
I0905 01:07:27.481401 2129298192 net.cpp:67] Creating Layer loss
I0905 01:07:27.481407 2129298192 net.cpp:394] loss <- fc2_fc2_0_split_0
I0905 01:07:27.481413 2129298192 net.cpp:394] loss <- label_data_1_split_0
I0905 01:07:27.481421 2129298192 net.cpp:356] loss -> loss
I0905 01:07:27.481434 2129298192 net.cpp:96] Setting up loss
I0905 01:07:27.481446 2129298192 net.cpp:103] Top shape: 1 1 1 1 (1)
I0905 01:07:27.481452 2129298192 net.cpp:109] with loss weight 1
I0905 01:07:27.481466 2129298192 net.cpp:67] Creating Layer accuracy
I0905 01:07:27.481472 2129298192 net.cpp:394] accuracy <- fc2_fc2_0_split_1
I0905 01:07:27.481504 2129298192 net.cpp:394] accuracy <- label_data_1_split_1
I0905 01:07:27.481513 2129298192 net.cpp:356] accuracy -> accuracy
I0905 01:07:27.481521 2129298192 net.cpp:96] Setting up accuracy
I0905 01:07:27.481528 2129298192 net.cpp:103] Top shape: 1 1 1 1 (1)
I0905 01:07:27.481534 2129298192 net.cpp:172] accuracy does not need backward computation.
I0905 01:07:27.481540 2129298192 net.cpp:170] loss needs backward computation.
I0905 01:07:27.481545 2129298192 net.cpp:170] fc2_fc2_0_split needs backward computation.
I0905 01:07:27.481551 2129298192 net.cpp:170] fc2 needs backward computation.
I0905 01:07:27.481557 2129298192 net.cpp:170] relu1 needs backward computation.
I0905 01:07:27.481562 2129298192 net.cpp:170] fc1 needs backward computation.
I0905 01:07:27.481569 2129298192 net.cpp:172] label_data_1_split does not need backward computation.
I0905 01:07:27.481575 2129298192 net.cpp:172] data does not need backward computation.
I0905 01:07:27.481730 2129298192 net.cpp:208] This network produces output accuracy
I0905 01:07:27.481742 2129298192 net.cpp:208] This network produces output loss
I0905 01:07:27.481758 2129298192 net.cpp:467] Collecting Learning Rate and Weight Decay.
I0905 01:07:27.481766 2129298192 net.cpp:219] Network initialization done.
I0905 01:07:27.481771 2129298192 net.cpp:220] Memory required for data: 3728
I0905 01:07:27.481814 2129298192 solver.cpp:46] Solver scaffolding done.
I0905 01:07:27.481822 2129298192 solver.cpp:165] Solving LogisticRegressionNet
I0905 01:07:27.481844 2129298192 solver.cpp:251] Iteration 0, Testing net (#0)
I0905 01:07:27.488900 2129298192 solver.cpp:302] Test net output #0: accuracy = 0.4924
I0905 01:07:27.488932 2129298192 solver.cpp:302] Test net output #1: loss = 0.693168 (* 1 = 0.693168 loss)
I0905 01:07:27.488962 2129298192 solver.cpp:195] Iteration 0, loss = 0.692972
I0905 01:07:27.488973 2129298192 solver.cpp:210] Train net output #0: loss = 0.692972 (* 1 = 0.692972 loss)
I0905 01:07:27.488984 2129298192 solver.cpp:405] Iteration 0, lr = 0.01
I0905 01:07:27.495033 2129298192 hdf5_data_layer.cpp:29] Loading HDF5 file/Users/sergeyk/work/caffe/examples/hdf5_classification/data/train.h5
I0905 01:07:27.495604 2129298192 hdf5_data_layer.cpp:49] Successully loaded 7500 rows
I0905 01:07:27.497684 2129298192 solver.cpp:251] Iteration 1000, Testing net (#0)
I0905 01:07:27.504875 2129298192 solver.cpp:302] Test net output #0: accuracy = 0.7744
I0905 01:07:27.504930 2129298192 solver.cpp:302] Test net output #1: loss = 0.486552 (* 1 = 0.486552 loss)
I0905 01:07:27.504955 2129298192 solver.cpp:195] Iteration 1000, loss = 0.660151
I0905 01:07:27.504966 2129298192 solver.cpp:210] Train net output #0: loss = 0.660151 (* 1 = 0.660151 loss)
I0905 01:07:27.504976 2129298192 solver.cpp:405] Iteration 1000, lr = 0.01
I0905 01:07:27.509419 2129298192 hdf5_data_layer.cpp:99] looping around to first file
I0905 01:07:27.509467 2129298192 hdf5_data_layer.cpp:29] Loading HDF5 file/Users/sergeyk/work/caffe/examples/hdf5_classification/data/train.h5
I0905 01:07:27.510288 2129298192 hdf5_data_layer.cpp:49] Successully loaded 7500 rows
I0905 01:07:27.514822 2129298192 solver.cpp:251] Iteration 2000, Testing net (#0)
I0905 01:07:27.522342 2129298192 solver.cpp:302] Test net output #0: accuracy = 0.8004
I0905 01:07:27.522444 2129298192 solver.cpp:302] Test net output #1: loss = 0.447153 (* 1 = 0.447153 loss)
I0905 01:07:27.522483 2129298192 solver.cpp:195] Iteration 2000, loss = 0.505697
I0905 01:07:27.522495 2129298192 solver.cpp:210] Train net output #0: loss = 0.505697 (* 1 = 0.505697 loss)
I0905 01:07:27.522507 2129298192 solver.cpp:405] Iteration 2000, lr = 0.01
I0905 01:07:27.524762 2129298192 hdf5_data_layer.cpp:29] Loading HDF5 file/Users/sergeyk/work/caffe/examples/hdf5_classification/data/train.h5
I0905 01:07:27.525921 2129298192 hdf5_data_layer.cpp:49] Successully loaded 7500 rows
I0905 01:07:27.533335 2129298192 solver.cpp:251] Iteration 3000, Testing net (#0)
I0905 01:07:27.541055 2129298192 solver.cpp:302] Test net output #0: accuracy = 0.8144
I0905 01:07:27.541146 2129298192 solver.cpp:302] Test net output #1: loss = 0.421441 (* 1 = 0.421441 loss)
I0905 01:07:27.541160 2129298192 hdf5_data_layer.cpp:99] looping around to first file
I0905 01:07:27.541167 2129298192 hdf5_data_layer.cpp:29] Loading HDF5 file/Users/sergeyk/work/caffe/examples/hdf5_classification/data/train.h5
I0905 01:07:27.542178 2129298192 hdf5_data_layer.cpp:49] Successully loaded 7500 rows
I0905 01:07:27.542261 2129298192 solver.cpp:195] Iteration 3000, loss = 0.242177
I0905 01:07:27.542284 2129298192 solver.cpp:210] Train net output #0: loss = 0.242177 (* 1 = 0.242177 loss)
I0905 01:07:27.542310 2129298192 solver.cpp:405] Iteration 3000, lr = 0.01
I0905 01:07:27.549348 2129298192 hdf5_data_layer.cpp:29] Loading HDF5 file/Users/sergeyk/work/caffe/examples/hdf5_classification/data/train.h5
I0905 01:07:27.550144 2129298192 hdf5_data_layer.cpp:49] Successully loaded 7500 rows
I0905 01:07:27.552340 2129298192 solver.cpp:251] Iteration 4000, Testing net (#0)
I0905 01:07:27.560089 2129298192 solver.cpp:302] Test net output #0: accuracy = 0.784001
I0905 01:07:27.560227 2129298192 solver.cpp:302] Test net output #1: loss = 0.4395 (* 1 = 0.4395 loss)
I0905 01:07:27.560286 2129298192 solver.cpp:195] Iteration 4000, loss = 1.01631
I0905 01:07:27.560302 2129298192 solver.cpp:210] Train net output #0: loss = 1.01631 (* 1 = 1.01631 loss)
I0905 01:07:27.560315 2129298192 solver.cpp:405] Iteration 4000, lr = 0.01
I0905 01:07:27.565016 2129298192 hdf5_data_layer.cpp:99] looping around to first file
I0905 01:07:27.565101 2129298192 hdf5_data_layer.cpp:29] Loading HDF5 file/Users/sergeyk/work/caffe/examples/hdf5_classification/data/train.h5
I0905 01:07:27.566145 2129298192 hdf5_data_layer.cpp:49] Successully loaded 7500 rows
I0905 01:07:27.570286 2129298192 solver.cpp:251] Iteration 5000, Testing net (#0)
I0905 01:07:27.577373 2129298192 solver.cpp:302] Test net output #0: accuracy = 0.802
I0905 01:07:27.577426 2129298192 solver.cpp:302] Test net output #1: loss = 0.463582 (* 1 = 0.463582 loss)
I0905 01:07:27.577452 2129298192 solver.cpp:195] Iteration 5000, loss = 0.632809
I0905 01:07:27.577463 2129298192 solver.cpp:210] Train net output #0: loss = 0.632809 (* 1 = 0.632809 loss)
I0905 01:07:27.577564 2129298192 solver.cpp:405] Iteration 5000, lr = 0.001
I0905 01:07:27.579649 2129298192 hdf5_data_layer.cpp:29] Loading HDF5 file/Users/sergeyk/work/caffe/examples/hdf5_classification/data/train.h5
I0905 01:07:27.580368 2129298192 hdf5_data_layer.cpp:49] Successully loaded 7500 rows
I0905 01:07:27.586956 2129298192 solver.cpp:251] Iteration 6000, Testing net (#0)
I0905 01:07:27.594288 2129298192 solver.cpp:302] Test net output #0: accuracy = 0.822
I0905 01:07:27.594327 2129298192 solver.cpp:302] Test net output #1: loss = 0.407026 (* 1 = 0.407026 loss)
I0905 01:07:27.594338 2129298192 hdf5_data_layer.cpp:99] looping around to first file
I0905 01:07:27.594344 2129298192 hdf5_data_layer.cpp:29] Loading HDF5 file/Users/sergeyk/work/caffe/examples/hdf5_classification/data/train.h5
I0905 01:07:27.594861 2129298192 hdf5_data_layer.cpp:49] Successully loaded 7500 rows
I0905 01:07:27.594897 2129298192 solver.cpp:195] Iteration 6000, loss = 0.214342
I0905 01:07:27.594910 2129298192 solver.cpp:210] Train net output #0: loss = 0.214342 (* 1 = 0.214342 loss)
I0905 01:07:27.594919 2129298192 solver.cpp:405] Iteration 6000, lr = 0.001
I0905 01:07:27.601003 2129298192 hdf5_data_layer.cpp:29] Loading HDF5 file/Users/sergeyk/work/caffe/examples/hdf5_classification/data/train.h5
I0905 01:07:27.601380 2129298192 hdf5_data_layer.cpp:49] Successully loaded 7500 rows
I0905 01:07:27.603358 2129298192 solver.cpp:251] Iteration 7000, Testing net (#0)
I0905 01:07:27.610307 2129298192 solver.cpp:302] Test net output #0: accuracy = 0.8264
I0905 01:07:27.610323 2129298192 solver.cpp:302] Test net output #1: loss = 0.403283 (* 1 = 0.403283 loss)
I0905 01:07:27.610342 2129298192 solver.cpp:195] Iteration 7000, loss = 0.894732
I0905 01:07:27.610352 2129298192 solver.cpp:210] Train net output #0: loss = 0.894732 (* 1 = 0.894732 loss)
I0905 01:07:27.610359 2129298192 solver.cpp:405] Iteration 7000, lr = 0.001
I0905 01:07:27.614289 2129298192 hdf5_data_layer.cpp:99] looping around to first file
I0905 01:07:27.614297 2129298192 hdf5_data_layer.cpp:29] Loading HDF5 file/Users/sergeyk/work/caffe/examples/hdf5_classification/data/train.h5
I0905 01:07:27.614701 2129298192 hdf5_data_layer.cpp:49] Successully loaded 7500 rows
I0905 01:07:27.618602 2129298192 solver.cpp:251] Iteration 8000, Testing net (#0)
I0905 01:07:27.625637 2129298192 solver.cpp:302] Test net output #0: accuracy = 0.8216
I0905 01:07:27.625661 2129298192 solver.cpp:302] Test net output #1: loss = 0.402446 (* 1 = 0.402446 loss)
I0905 01:07:27.625680 2129298192 solver.cpp:195] Iteration 8000, loss = 0.500503
I0905 01:07:27.625690 2129298192 solver.cpp:210] Train net output #0: loss = 0.500503 (* 1 = 0.500503 loss)
I0905 01:07:27.625707 2129298192 solver.cpp:405] Iteration 8000, lr = 0.001
I0905 01:07:27.627665 2129298192 hdf5_data_layer.cpp:29] Loading HDF5 file/Users/sergeyk/work/caffe/examples/hdf5_classification/data/train.h5
I0905 01:07:27.628075 2129298192 hdf5_data_layer.cpp:49] Successully loaded 7500 rows
I0905 01:07:27.634202 2129298192 solver.cpp:251] Iteration 9000, Testing net (#0)
I0905 01:07:27.641368 2129298192 solver.cpp:302] Test net output #0: accuracy = 0.8252
I0905 01:07:27.641412 2129298192 solver.cpp:302] Test net output #1: loss = 0.404175 (* 1 = 0.404175 loss)
I0905 01:07:27.641422 2129298192 hdf5_data_layer.cpp:99] looping around to first file
I0905 01:07:27.641428 2129298192 hdf5_data_layer.cpp:29] Loading HDF5 file/Users/sergeyk/work/caffe/examples/hdf5_classification/data/train.h5
I0905 01:07:27.641960 2129298192 hdf5_data_layer.cpp:49] Successully loaded 7500 rows
I0905 01:07:27.642004 2129298192 solver.cpp:195] Iteration 9000, loss = 0.201587
I0905 01:07:27.642016 2129298192 solver.cpp:210] Train net output #0: loss = 0.201587 (* 1 = 0.201587 loss)
I0905 01:07:27.642026 2129298192 solver.cpp:405] Iteration 9000, lr = 0.001
I0905 01:07:27.648680 2129298192 hdf5_data_layer.cpp:29] Loading HDF5 file/Users/sergeyk/work/caffe/examples/hdf5_classification/data/train.h5
I0905 01:07:27.649211 2129298192 hdf5_data_layer.cpp:49] Successully loaded 7500 rows
I0905 01:07:27.651327 2129298192 solver.cpp:319] Snapshotting to examples/hdf5_classification/data/train_iter_10000
I0905 01:07:27.651476 2129298192 solver.cpp:326] Snapshotting solver state to examples/hdf5_classification/data/train_iter_10000.solverstate
I0905 01:07:27.651564 2129298192 solver.cpp:232] Iteration 10000, loss = 0.935422
I0905 01:07:27.651582 2129298192 solver.cpp:251] Iteration 10000, Testing net (#0)
I0905 01:07:27.658738 2129298192 solver.cpp:302] Test net output #0: accuracy = 0.826
I0905 01:07:27.658782 2129298192 solver.cpp:302] Test net output #1: loss = 0.400826 (* 1 = 0.400826 loss)
I0905 01:07:27.658790 2129298192 solver.cpp:237] Optimization Done.
I0905 01:07:27.658797 2129298192 caffe.cpp:114] Optimization Done.
In [8]:
# Clean up (comment this out if you want to examine the hdf5_classification/data directory).
shutil.rmtree(dirname)
Content source: austinjalexander/sandbox
Similar notebooks: