import caffe
import numpy
my_sgd=caffe.SGDSolver('my_solver.prototext')
# solver file references a net file whose 1st layer looks like this:
# layers {
# name: "mem_data"# type: MEMORY_DATA# top: "data"# top: "label"# memory_data_param {# batch_size: 10# channels: 4# height: 1# width: 1# }# }
# numpy.shape(my_data) returns (100, 4, 1, 1)
# numpy.shape(my_labels) returns (100, 1, 1, 1)
my_sgd.net.set_input_arrays( my_data, my_labels )
my_sgd.solve()
# outputs:# I1109 16:25:52.994668 4896 solver.cpp:160] Solving LogisticRegressionNet# I1109 16:25:52.994711 4896 solver.cpp:247] Iteration 0, Testing net (#0)# F1109 16:25:52.994727 4896 memory_data_layer.cpp:70] Check failed: data_ MemoryDataLayer needs to be initalized by calling Reset# *** Check failure stack trace: ***# Aborted (core dumped)
name:"LeNet" input: "data" input_dim: 64 input_dim: 1 input_dim: 28 input_dim: 28 And the rest parts of network configs are the same as normal configuration in C+++ version. A reference for this: https://github.com/BVLC/caffe/blob/master/examples/mnist/lenet.prototxt | |