Classification with HDF5 data

In this example we'll use Caffe to do simple logistic regression on a simple binary dataset, showcasing HDF5DataLayer functionality.


In [1]:
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 [2]:
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 [3]:
# 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 [4]:
# 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.763

In [5]:
# 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 [6]:
# 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


I0905 01:07:27.099238 2129298192 caffe.cpp:90] Starting Optimization
I0905 01:07:27.100469 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_val.prototxt"
I0905 01:07:27.100630 2129298192 solver.cpp:72] Creating training net from net file: examples/hdf5_classification/train_val.prototxt
I0905 01:07:27.100988 2129298192 net.cpp:275] The NetState phase (0) differed from the phase (1) specified by a rule in layer data
I0905 01:07:27.101011 2129298192 net.cpp:275] The NetState phase (0) differed from the phase (1) specified by a rule in layer accuracy
I0905 01:07:27.101022 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: 2
    weight_filler {
      type: "gaussian"
      std: 0.01
    }
    bias_filler {
      type: "constant"
      value: 0
    }
  }
}
layers {
  bottom: "fc1"
  bottom: "label"
  top: "loss"
  name: "loss"
  type: SOFTMAX_LOSS
}
state {
  phase: TRAIN
}
I0905 01:07:27.105614 2129298192 net.cpp:67] Creating Layer data
I0905 01:07:27.105664 2129298192 net.cpp:356] data -> data
I0905 01:07:27.105698 2129298192 net.cpp:356] data -> label
I0905 01:07:27.105710 2129298192 net.cpp:96] Setting up data
I0905 01:07:27.105717 2129298192 hdf5_data_layer.cpp:57] Loading filename from examples/hdf5_classification/data/train.txt
I0905 01:07:27.105813 2129298192 hdf5_data_layer.cpp:69] Number of files: 2
I0905 01:07:27.105828 2129298192 hdf5_data_layer.cpp:29] Loading HDF5 file/Users/sergeyk/work/caffe/examples/hdf5_classification/data/train.h5
I0905 01:07:27.109418 2129298192 hdf5_data_layer.cpp:49] Successully loaded 7500 rows
I0905 01:07:27.109501 2129298192 hdf5_data_layer.cpp:81] output data size: 10,4,1,1
I0905 01:07:27.109522 2129298192 net.cpp:103] Top shape: 10 4 1 1 (40)
I0905 01:07:27.109531 2129298192 net.cpp:103] Top shape: 10 1 1 1 (10)
I0905 01:07:27.109560 2129298192 net.cpp:67] Creating Layer fc1
I0905 01:07:27.109570 2129298192 net.cpp:394] fc1 <- data
I0905 01:07:27.109590 2129298192 net.cpp:356] fc1 -> fc1
I0905 01:07:27.109618 2129298192 net.cpp:96] Setting up fc1
I0905 01:07:27.115136 2129298192 net.cpp:103] Top shape: 10 2 1 1 (20)
I0905 01:07:27.115190 2129298192 net.cpp:67] Creating Layer loss
I0905 01:07:27.115198 2129298192 net.cpp:394] loss <- fc1
I0905 01:07:27.115206 2129298192 net.cpp:394] loss <- label
I0905 01:07:27.115214 2129298192 net.cpp:356] loss -> loss
I0905 01:07:27.115224 2129298192 net.cpp:96] Setting up loss
I0905 01:07:27.115237 2129298192 net.cpp:103] Top shape: 1 1 1 1 (1)
I0905 01:07:27.115244 2129298192 net.cpp:109]     with loss weight 1
I0905 01:07:27.115260 2129298192 net.cpp:170] loss needs backward computation.
I0905 01:07:27.115267 2129298192 net.cpp:170] fc1 needs backward computation.
I0905 01:07:27.115273 2129298192 net.cpp:172] data does not need backward computation.
I0905 01:07:27.115278 2129298192 net.cpp:208] This network produces output loss
I0905 01:07:27.115288 2129298192 net.cpp:467] Collecting Learning Rate and Weight Decay.
I0905 01:07:27.115295 2129298192 net.cpp:219] Network initialization done.
I0905 01:07:27.115301 2129298192 net.cpp:220] Memory required for data: 284
I0905 01:07:27.115622 2129298192 solver.cpp:156] Creating test net (#0) specified by net file: examples/hdf5_classification/train_val.prototxt
I0905 01:07:27.115644 2129298192 net.cpp:275] The NetState phase (1) differed from the phase (0) specified by a rule in layer data
I0905 01:07:27.115656 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: 2
    weight_filler {
      type: "gaussian"
      std: 0.01
    }
    bias_filler {
      type: "constant"
      value: 0
    }
  }
}
layers {
  bottom: "fc1"
  bottom: "label"
  top: "loss"
  name: "loss"
  type: SOFTMAX_LOSS
}
layers {
  bottom: "fc1"
  bottom: "label"
  top: "accuracy"
  name: "accuracy"
  type: ACCURACY
  include {
    phase: TEST
  }
}
state {
  phase: TEST
}
I0905 01:07:27.115854 2129298192 net.cpp:67] Creating Layer data
I0905 01:07:27.115864 2129298192 net.cpp:356] data -> data
I0905 01:07:27.116004 2129298192 net.cpp:356] data -> label
I0905 01:07:27.116024 2129298192 net.cpp:96] Setting up data
I0905 01:07:27.116030 2129298192 hdf5_data_layer.cpp:57] Loading filename from examples/hdf5_classification/data/test.txt
I0905 01:07:27.116080 2129298192 hdf5_data_layer.cpp:69] Number of files: 1
I0905 01:07:27.116089 2129298192 hdf5_data_layer.cpp:29] Loading HDF5 file/Users/sergeyk/work/caffe/examples/hdf5_classification/data/test.h5
I0905 01:07:27.117313 2129298192 hdf5_data_layer.cpp:49] Successully loaded 2500 rows
I0905 01:07:27.117348 2129298192 hdf5_data_layer.cpp:81] output data size: 10,4,1,1
I0905 01:07:27.117357 2129298192 net.cpp:103] Top shape: 10 4 1 1 (40)
I0905 01:07:27.117364 2129298192 net.cpp:103] Top shape: 10 1 1 1 (10)
I0905 01:07:27.117377 2129298192 net.cpp:67] Creating Layer label_data_1_split
I0905 01:07:27.117384 2129298192 net.cpp:394] label_data_1_split <- label
I0905 01:07:27.117393 2129298192 net.cpp:356] label_data_1_split -> label_data_1_split_0
I0905 01:07:27.117409 2129298192 net.cpp:356] label_data_1_split -> label_data_1_split_1
I0905 01:07:27.117419 2129298192 net.cpp:96] Setting up label_data_1_split
I0905 01:07:27.117427 2129298192 net.cpp:103] Top shape: 10 1 1 1 (10)
I0905 01:07:27.117434 2129298192 net.cpp:103] Top shape: 10 1 1 1 (10)
I0905 01:07:27.117444 2129298192 net.cpp:67] Creating Layer fc1
I0905 01:07:27.117449 2129298192 net.cpp:394] fc1 <- data
I0905 01:07:27.117470 2129298192 net.cpp:356] fc1 -> fc1
I0905 01:07:27.117478 2129298192 net.cpp:96] Setting up fc1
I0905 01:07:27.117506 2129298192 net.cpp:103] Top shape: 10 2 1 1 (20)
I0905 01:07:27.117519 2129298192 net.cpp:67] Creating Layer fc1_fc1_0_split
I0905 01:07:27.117527 2129298192 net.cpp:394] fc1_fc1_0_split <- fc1
I0905 01:07:27.117534 2129298192 net.cpp:356] fc1_fc1_0_split -> fc1_fc1_0_split_0
I0905 01:07:27.117543 2129298192 net.cpp:356] fc1_fc1_0_split -> fc1_fc1_0_split_1
I0905 01:07:27.117640 2129298192 net.cpp:96] Setting up fc1_fc1_0_split
I0905 01:07:27.117655 2129298192 net.cpp:103] Top shape: 10 2 1 1 (20)
I0905 01:07:27.117662 2129298192 net.cpp:103] Top shape: 10 2 1 1 (20)
I0905 01:07:27.117673 2129298192 net.cpp:67] Creating Layer loss
I0905 01:07:27.117679 2129298192 net.cpp:394] loss <- fc1_fc1_0_split_0
I0905 01:07:27.117687 2129298192 net.cpp:394] loss <- label_data_1_split_0
I0905 01:07:27.117696 2129298192 net.cpp:356] loss -> loss
I0905 01:07:27.117704 2129298192 net.cpp:96] Setting up loss
I0905 01:07:27.117717 2129298192 net.cpp:103] Top shape: 1 1 1 1 (1)
I0905 01:07:27.117723 2129298192 net.cpp:109]     with loss weight 1
I0905 01:07:27.117743 2129298192 net.cpp:67] Creating Layer accuracy
I0905 01:07:27.117749 2129298192 net.cpp:394] accuracy <- fc1_fc1_0_split_1
I0905 01:07:27.117756 2129298192 net.cpp:394] accuracy <- label_data_1_split_1
I0905 01:07:27.117764 2129298192 net.cpp:356] accuracy -> accuracy
I0905 01:07:27.117774 2129298192 net.cpp:96] Setting up accuracy
I0905 01:07:27.117781 2129298192 net.cpp:103] Top shape: 1 1 1 1 (1)
I0905 01:07:27.117789 2129298192 net.cpp:172] accuracy does not need backward computation.
I0905 01:07:27.117794 2129298192 net.cpp:170] loss needs backward computation.
I0905 01:07:27.117835 2129298192 net.cpp:170] fc1_fc1_0_split needs backward computation.
I0905 01:07:27.117842 2129298192 net.cpp:170] fc1 needs backward computation.
I0905 01:07:27.117848 2129298192 net.cpp:172] label_data_1_split does not need backward computation.
I0905 01:07:27.117854 2129298192 net.cpp:172] data does not need backward computation.
I0905 01:07:27.117861 2129298192 net.cpp:208] This network produces output accuracy
I0905 01:07:27.117866 2129298192 net.cpp:208] This network produces output loss
I0905 01:07:27.117877 2129298192 net.cpp:467] Collecting Learning Rate and Weight Decay.
I0905 01:07:27.117926 2129298192 net.cpp:219] Network initialization done.
I0905 01:07:27.117938 2129298192 net.cpp:220] Memory required for data: 528
I0905 01:07:27.117985 2129298192 solver.cpp:46] Solver scaffolding done.
I0905 01:07:27.117992 2129298192 solver.cpp:165] Solving LogisticRegressionNet
I0905 01:07:27.118026 2129298192 solver.cpp:251] Iteration 0, Testing net (#0)
I0905 01:07:27.123764 2129298192 solver.cpp:302]     Test net output #0: accuracy = 0.646801
I0905 01:07:27.123847 2129298192 solver.cpp:302]     Test net output #1: loss = 0.690777 (* 1 = 0.690777 loss)
I0905 01:07:27.123888 2129298192 solver.cpp:195] Iteration 0, loss = 0.689469
I0905 01:07:27.123898 2129298192 solver.cpp:210]     Train net output #0: loss = 0.689469 (* 1 = 0.689469 loss)
I0905 01:07:27.123915 2129298192 solver.cpp:405] Iteration 0, lr = 0.01
I0905 01:07:27.127096 2129298192 hdf5_data_layer.cpp:29] Loading HDF5 file/Users/sergeyk/work/caffe/examples/hdf5_classification/data/train.h5
I0905 01:07:27.128094 2129298192 hdf5_data_layer.cpp:49] Successully loaded 7500 rows
I0905 01:07:27.129258 2129298192 solver.cpp:251] Iteration 1000, Testing net (#0)
I0905 01:07:27.135226 2129298192 solver.cpp:302]     Test net output #0: accuracy = 0.745599
I0905 01:07:27.135296 2129298192 solver.cpp:302]     Test net output #1: loss = 0.573658 (* 1 = 0.573658 loss)
I0905 01:07:27.135315 2129298192 solver.cpp:195] Iteration 1000, loss = 0.49682
I0905 01:07:27.135325 2129298192 solver.cpp:210]     Train net output #0: loss = 0.49682 (* 1 = 0.49682 loss)
I0905 01:07:27.135334 2129298192 solver.cpp:405] Iteration 1000, lr = 0.01
I0905 01:07:27.137315 2129298192 hdf5_data_layer.cpp:99] looping around to first file
I0905 01:07:27.137358 2129298192 hdf5_data_layer.cpp:29] Loading HDF5 file/Users/sergeyk/work/caffe/examples/hdf5_classification/data/train.h5
I0905 01:07:27.138335 2129298192 hdf5_data_layer.cpp:49] Successully loaded 7500 rows
I0905 01:07:27.140410 2129298192 solver.cpp:251] Iteration 2000, Testing net (#0)
I0905 01:07:27.147435 2129298192 solver.cpp:302]     Test net output #0: accuracy = 0.746399
I0905 01:07:27.147514 2129298192 solver.cpp:302]     Test net output #1: loss = 0.582127 (* 1 = 0.582127 loss)
I0905 01:07:27.147541 2129298192 solver.cpp:195] Iteration 2000, loss = 0.555272
I0905 01:07:27.147553 2129298192 solver.cpp:210]     Train net output #0: loss = 0.555272 (* 1 = 0.555272 loss)
I0905 01:07:27.147565 2129298192 solver.cpp:405] Iteration 2000, lr = 0.01
I0905 01:07:27.148572 2129298192 hdf5_data_layer.cpp:29] Loading HDF5 file/Users/sergeyk/work/caffe/examples/hdf5_classification/data/train.h5
I0905 01:07:27.149441 2129298192 hdf5_data_layer.cpp:49] Successully loaded 7500 rows
I0905 01:07:27.152377 2129298192 solver.cpp:251] Iteration 3000, Testing net (#0)
I0905 01:07:27.158655 2129298192 solver.cpp:302]     Test net output #0: accuracy = 0.696
I0905 01:07:27.158746 2129298192 solver.cpp:302]     Test net output #1: loss = 0.580239 (* 1 = 0.580239 loss)
I0905 01:07:27.158761 2129298192 hdf5_data_layer.cpp:99] looping around to first file
I0905 01:07:27.158768 2129298192 hdf5_data_layer.cpp:29] Loading HDF5 file/Users/sergeyk/work/caffe/examples/hdf5_classification/data/train.h5
I0905 01:07:27.159765 2129298192 hdf5_data_layer.cpp:49] Successully loaded 7500 rows
I0905 01:07:27.159843 2129298192 solver.cpp:195] Iteration 3000, loss = 0.476517
I0905 01:07:27.159873 2129298192 solver.cpp:210]     Train net output #0: loss = 0.476517 (* 1 = 0.476517 loss)
I0905 01:07:27.159983 2129298192 solver.cpp:405] Iteration 3000, lr = 0.01
I0905 01:07:27.163079 2129298192 hdf5_data_layer.cpp:29] Loading HDF5 file/Users/sergeyk/work/caffe/examples/hdf5_classification/data/train.h5
I0905 01:07:27.163602 2129298192 hdf5_data_layer.cpp:49] Successully loaded 7500 rows
I0905 01:07:27.164567 2129298192 solver.cpp:251] Iteration 4000, Testing net (#0)
I0905 01:07:27.170277 2129298192 solver.cpp:302]     Test net output #0: accuracy = 0.745599
I0905 01:07:27.170344 2129298192 solver.cpp:302]     Test net output #1: loss = 0.573658 (* 1 = 0.573658 loss)
I0905 01:07:27.170364 2129298192 solver.cpp:195] Iteration 4000, loss = 0.49682
I0905 01:07:27.170375 2129298192 solver.cpp:210]     Train net output #0: loss = 0.49682 (* 1 = 0.49682 loss)
I0905 01:07:27.170385 2129298192 solver.cpp:405] Iteration 4000, lr = 0.01
I0905 01:07:27.172350 2129298192 hdf5_data_layer.cpp:99] looping around to first file
I0905 01:07:27.172374 2129298192 hdf5_data_layer.cpp:29] Loading HDF5 file/Users/sergeyk/work/caffe/examples/hdf5_classification/data/train.h5
I0905 01:07:27.173084 2129298192 hdf5_data_layer.cpp:49] Successully loaded 7500 rows
I0905 01:07:27.175192 2129298192 solver.cpp:251] Iteration 5000, Testing net (#0)
I0905 01:07:27.181659 2129298192 solver.cpp:302]     Test net output #0: accuracy = 0.746399
I0905 01:07:27.181710 2129298192 solver.cpp:302]     Test net output #1: loss = 0.582127 (* 1 = 0.582127 loss)
I0905 01:07:27.181730 2129298192 solver.cpp:195] Iteration 5000, loss = 0.555272
I0905 01:07:27.181740 2129298192 solver.cpp:210]     Train net output #0: loss = 0.555272 (* 1 = 0.555272 loss)
I0905 01:07:27.181748 2129298192 solver.cpp:405] Iteration 5000, lr = 0.001
I0905 01:07:27.182734 2129298192 hdf5_data_layer.cpp:29] Loading HDF5 file/Users/sergeyk/work/caffe/examples/hdf5_classification/data/train.h5
I0905 01:07:27.183248 2129298192 hdf5_data_layer.cpp:49] Successully loaded 7500 rows
I0905 01:07:27.186180 2129298192 solver.cpp:251] Iteration 6000, Testing net (#0)
I0905 01:07:27.192646 2129298192 solver.cpp:302]     Test net output #0: accuracy = 0.7684
I0905 01:07:27.192751 2129298192 solver.cpp:302]     Test net output #1: loss = 0.574538 (* 1 = 0.574538 loss)
I0905 01:07:27.192766 2129298192 hdf5_data_layer.cpp:99] looping around to first file
I0905 01:07:27.192773 2129298192 hdf5_data_layer.cpp:29] Loading HDF5 file/Users/sergeyk/work/caffe/examples/hdf5_classification/data/train.h5
I0905 01:07:27.193936 2129298192 hdf5_data_layer.cpp:49] Successully loaded 7500 rows
I0905 01:07:27.194007 2129298192 solver.cpp:195] Iteration 6000, loss = 0.464052
I0905 01:07:27.194036 2129298192 solver.cpp:210]     Train net output #0: loss = 0.464052 (* 1 = 0.464052 loss)
I0905 01:07:27.194051 2129298192 solver.cpp:405] Iteration 6000, lr = 0.001
I0905 01:07:27.197053 2129298192 hdf5_data_layer.cpp:29] Loading HDF5 file/Users/sergeyk/work/caffe/examples/hdf5_classification/data/train.h5
I0905 01:07:27.198092 2129298192 hdf5_data_layer.cpp:49] Successully loaded 7500 rows
I0905 01:07:27.199162 2129298192 solver.cpp:251] Iteration 7000, Testing net (#0)
I0905 01:07:27.205195 2129298192 solver.cpp:302]     Test net output #0: accuracy = 0.7684
I0905 01:07:27.205298 2129298192 solver.cpp:302]     Test net output #1: loss = 0.574549 (* 1 = 0.574549 loss)
I0905 01:07:27.205327 2129298192 solver.cpp:195] Iteration 7000, loss = 0.495483
I0905 01:07:27.205338 2129298192 solver.cpp:210]     Train net output #0: loss = 0.495483 (* 1 = 0.495483 loss)
I0905 01:07:27.205353 2129298192 solver.cpp:405] Iteration 7000, lr = 0.001
I0905 01:07:27.207471 2129298192 hdf5_data_layer.cpp:99] looping around to first file
I0905 01:07:27.207489 2129298192 hdf5_data_layer.cpp:29] Loading HDF5 file/Users/sergeyk/work/caffe/examples/hdf5_classification/data/train.h5
I0905 01:07:27.208534 2129298192 hdf5_data_layer.cpp:49] Successully loaded 7500 rows
I0905 01:07:27.210860 2129298192 solver.cpp:251] Iteration 8000, Testing net (#0)
I0905 01:07:27.216624 2129298192 solver.cpp:302]     Test net output #0: accuracy = 0.762
I0905 01:07:27.216704 2129298192 solver.cpp:302]     Test net output #1: loss = 0.574515 (* 1 = 0.574515 loss)
I0905 01:07:27.216723 2129298192 solver.cpp:195] Iteration 8000, loss = 0.524565
I0905 01:07:27.216733 2129298192 solver.cpp:210]     Train net output #0: loss = 0.524565 (* 1 = 0.524565 loss)
I0905 01:07:27.216743 2129298192 solver.cpp:405] Iteration 8000, lr = 0.001
I0905 01:07:27.217738 2129298192 hdf5_data_layer.cpp:29] Loading HDF5 file/Users/sergeyk/work/caffe/examples/hdf5_classification/data/train.h5
I0905 01:07:27.218291 2129298192 hdf5_data_layer.cpp:49] Successully loaded 7500 rows
I0905 01:07:27.221294 2129298192 solver.cpp:251] Iteration 9000, Testing net (#0)
I0905 01:07:27.227104 2129298192 solver.cpp:302]     Test net output #0: accuracy = 0.7688
I0905 01:07:27.227171 2129298192 solver.cpp:302]     Test net output #1: loss = 0.574278 (* 1 = 0.574278 loss)
I0905 01:07:27.227183 2129298192 hdf5_data_layer.cpp:99] looping around to first file
I0905 01:07:27.227190 2129298192 hdf5_data_layer.cpp:29] Loading HDF5 file/Users/sergeyk/work/caffe/examples/hdf5_classification/data/train.h5
I0905 01:07:27.228143 2129298192 hdf5_data_layer.cpp:49] Successully loaded 7500 rows
I0905 01:07:27.228210 2129298192 solver.cpp:195] Iteration 9000, loss = 0.461831
I0905 01:07:27.228240 2129298192 solver.cpp:210]     Train net output #0: loss = 0.461831 (* 1 = 0.461831 loss)
I0905 01:07:27.228252 2129298192 solver.cpp:405] Iteration 9000, lr = 0.001
I0905 01:07:27.231314 2129298192 hdf5_data_layer.cpp:29] Loading HDF5 file/Users/sergeyk/work/caffe/examples/hdf5_classification/data/train.h5
I0905 01:07:27.232293 2129298192 hdf5_data_layer.cpp:49] Successully loaded 7500 rows
I0905 01:07:27.233417 2129298192 solver.cpp:319] Snapshotting to examples/hdf5_classification/data/train_iter_10000
I0905 01:07:27.233680 2129298192 solver.cpp:326] Snapshotting solver state to examples/hdf5_classification/data/train_iter_10000.solverstate
I0905 01:07:27.233795 2129298192 solver.cpp:232] Iteration 10000, loss = 0.49554
I0905 01:07:27.233814 2129298192 solver.cpp:251] Iteration 10000, Testing net (#0)
I0905 01:07:27.240015 2129298192 solver.cpp:302]     Test net output #0: accuracy = 0.768
I0905 01:07:27.240099 2129298192 solver.cpp:302]     Test net output #1: loss = 0.574488 (* 1 = 0.574488 loss)
I0905 01:07:27.240110 2129298192 solver.cpp:237] Optimization Done.
I0905 01:07:27.240118 2129298192 caffe.cpp:114] Optimization Done.

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)