What is the correct way of using MemoryData layer using pycaffe?

34 views
Skip to first unread message

Frank Darius

unread,
Apr 5, 2017, 1:50:43 PM4/5/17
to Caffe Users
I'm planning to do real-time augmentation in `caffe`. and these are the steps I have taken so far:   
1.Replace `Data` layer with `MemoryData` in the network:


    name
: "test_network"
    layer
{
      name
: "test_data"
      type
: "MemoryData"
      top
: "data"
      top
: "label"
      include
{
        phase
: TRAIN
     
}
      memory_data_param
{
       batch_size
: 32
       channels
: 3
       height
: 32
       width
: 32
     
}
   
   
}
    layer
{
      name
: "test_data"
      type
: "MemoryData"
      top
: "data"
      top
: "label"
      include
{
        phase
: TEST
     
}
       memory_data_param
{
       batch_size
: 32
       channels
: 3
       height
: 32
       width
: 32
     
}
   
}


and this is the code for training : 


    caffe.set_mode_gpu()
    maxIter
= 100
    batch_size
= 32
    j
= 0
   
for i in range(maxIter):
       
#fetch images
        batch
= seq.augment_images(np.transpose(data_train[j: j+batch_size],(0,2,3,1)))
       
print('batch-{0}-{1}'.format(j,j+batch_size))
       
#set input and solve
        batch
= batch.reshape(-1,3,32,32).astype(np.float32)
        net
.set_input_arrays(batch, label_train[j: j+batch_size].astype(np.float32))
        j
= j + batch_size + 1
        solver
.step(1)


but when the code reaches to the net.set_input_arrays(), it crashes with this error:
   
 W0405 20:53:19.679730  4640 memory_data_layer.cpp:90] MemoryData does not transform array data on Reset()
    I0405
20:53:19.713727  4640 solver.cpp:337] Iteration 0, Testing net (#0)
    I0405
20:53:19.719229  4640 net.cpp:685] Ignoring source layer accuracy_training
    F0405
20:53:19.719229  4640 memory_data_layer.cpp:110] Check failed: data_ MemoryDataLayer needs to be initalized by calling Reset
   
*** Check failure stack trace: ***

I cant find the reset() method anywhere, Is this layer even supported properly? there is zero documentation about this. 
The c++ interface has some explanations! but the python wrapper has nothing! 
At the very least an example for this layer is appreciated.    
Reply all
Reply to author
Forward
0 new messages