agethen / ConvLSTM-for-Caffe

28 stars 15 forks source link

Still have problems with preparing dataset? #13

Open ksnzh opened 6 years ago

ksnzh commented 6 years ago

I followed #4 to prepare Moving-mnist dataset. This is my code to generate .h5 file for training.

import numpy
import h5py

# Load data
file = numpy.load( "moving-mnist-train.npz" )
# file = numpy.load( "moving-mnist-test.npz" )

# Select data field
data = file['input_raw_data']

# As you can see, the shape is N*T x C x H x W, so we need to change that
print data.shape

# Reshape to N x T x C x H x W
tmp = numpy.reshape( data, (data.shape[0]/20, 20, 1, 64, 64) )

# Swap T and N
res = numpy.swapaxes( tmp, 0, 1 )
i = 0
for idx in range( 0, res.shape[1], 16):
  print "File ", i
  # Pick the n-th item along N axis (while keeping shape)
  datum_fir = res[0:10,idx:idx+16]

  # Open a file handle
  h5file = h5py.File( "train/file_" + str( i ).zfill(5) + ".h5", 'w' )
  # h5file = h5py.File( "test/file_" + str( i ).zfill(5) + ".h5", 'w' )

  # Create a dataset with name "data"
  input_data = h5file.create_dataset( "input", shape = datum_fir.shape, dtype = numpy.float32 )
  # Copy data
  input_data[:] = datum_fir

  datum_sec = res[10:20,idx+16:idx+32]
  # Create a dataset with name "data"
  match_data = h5file.create_dataset( "match", shape = datum_sec.shape, dtype = numpy.float32 )
  # Copy data
  match_data[:] = datum_sec

  i += 1
  # Close file
  h5file.close()

print "Done!"

Assuming T=20(10 for encode, 10 for decode), N=16(16 indeodent samples), the size of input and match should be 10x16x16x16x16?

This is part of error information:

I1213 00:08:17.193084 30426 net.cpp:217] h_t=1_encode1_unit_t=1_1_split needs backward computation.
I1213 00:08:17.193086 30426 net.cpp:217] c_t=1_encode1_unit_t=1_0_split needs backward computation.
I1213 00:08:17.193089 30426 net.cpp:217] encode1_unit_t=1 needs backward computation.
I1213 00:08:17.193091 30426 net.cpp:217] encode1_gate_input_1 needs backward computation.
I1213 00:08:17.193094 30426 net.cpp:217] encode1_concat_hadamard_t=1 needs backward computation.
I1213 00:08:17.193099 30426 net.cpp:219] encode1_hadamard_gat_t=1 does not need backward computation.
I1213 00:08:17.193104 30426 net.cpp:217] encode1_hadamard->output_t=0 needs backward computation.
I1213 00:08:17.193106 30426 net.cpp:217] encode1_hadamard->forget_t=0 needs backward computation.
I1213 00:08:17.193109 30426 net.cpp:217] encode1_hadamard->input_t=0 needs backward computation.
I1213 00:08:17.193111 30426 net.cpp:217] encode1_hidden->transform->0 needs backward computation.
I1213 00:08:17.193114 30426 net.cpp:217] encode1_h_conted_t=0 needs backward computation.
I1213 00:08:17.193116 30426 net.cpp:217] encode1_dummy_forward_h0 needs backward computation.
I1213 00:08:17.193120 30426 net.cpp:217] c_t=0_encode1_dummy_forward_c0_0_split needs backward computation.
I1213 00:08:17.193121 30426 net.cpp:217] encode1_dummy_forward_c0 needs backward computation.
I1213 00:08:17.193125 30426 net.cpp:219] cont_t=10_encode1_cont_slice_9_split does not need backward computation.
I1213 00:08:17.193127 30426 net.cpp:219] cont_t=9_encode1_cont_slice_8_split does not need backward computation.
I1213 00:08:17.193130 30426 net.cpp:219] cont_t=8_encode1_cont_slice_7_split does not need backward computation.
I1213 00:08:17.193132 30426 net.cpp:219] cont_t=7_encode1_cont_slice_6_split does not need backward computation.
I1213 00:08:17.193135 30426 net.cpp:219] cont_t=6_encode1_cont_slice_5_split does not need backward computation.
I1213 00:08:17.193137 30426 net.cpp:219] cont_t=5_encode1_cont_slice_4_split does not need backward computation.
I1213 00:08:17.193140 30426 net.cpp:219] cont_t=4_encode1_cont_slice_3_split does not need backward computation.
I1213 00:08:17.193143 30426 net.cpp:219] cont_t=3_encode1_cont_slice_2_split does not need backward computation.
I1213 00:08:17.193145 30426 net.cpp:219] cont_t=2_encode1_cont_slice_1_split does not need backward computation.
I1213 00:08:17.193148 30426 net.cpp:219] cont_t=1_encode1_cont_slice_0_split does not need backward computation.
I1213 00:08:17.193152 30426 net.cpp:219] encode1_cont_slice does not need backward computation.
I1213 00:08:17.193155 30426 net.cpp:217] encode1_W_xc_x_slice needs backward computation.
I1213 00:08:17.193157 30426 net.cpp:219] encode1_input->cell_hidden does not need backward computation.
I1213 00:08:17.193159 30426 net.cpp:217] encode1_x->transform needs backward computation.
I1213 00:08:17.193161 30426 net.cpp:219] encode1_ does not need backward computation.
I1213 00:08:17.193163 30426 net.cpp:261] This network produces output c_t=T_pseudoloss
I1213 00:08:17.193167 30426 net.cpp:261] This network produces output h_pseudoloss
I1213 00:08:17.193171 30426 net.cpp:261] This network produces output h_t=T_pseudoloss
I1213 00:08:17.214619 30426 net.cpp:274] Network initialization done.
I1213 00:08:17.214865 30426 recurrent_layer.cpp:150] Adding parameter 0: x_transform
I1213 00:08:17.214870 30426 recurrent_layer.cpp:150] Adding parameter 1: 0
I1213 00:08:17.214872 30426 recurrent_layer.cpp:150] Adding parameter 2: 0
I1213 00:08:17.214874 30426 recurrent_layer.cpp:150] Adding parameter 3: h->transform
I1213 00:08:17.214876 30426 recurrent_layer.cpp:150] Adding parameter 4: h->transform_bias
I1213 00:08:17.214879 30426 recurrent_layer.cpp:150] Adding parameter 5: hadamard.input
I1213 00:08:17.214879 30426 recurrent_layer.cpp:150] Adding parameter 6: hadamard.forget
I1213 00:08:17.214881 30426 recurrent_layer.cpp:150] Adding parameter 7: hadamard.output
I1213 00:08:17.214884 30426 recurrent_layer.cpp:150] Adding parameter 53: 0
I1213 00:08:17.214885 30426 recurrent_layer.cpp:150] Adding parameter 54: 0
F1213 00:08:17.326793 30426 recurrent_layer.cpp:216] Check failed: recur_input_blobs_[j]->shape() == bottom[i]->shape() bottom[2] shape must match hidden state input shape: 1 16 256 64 64 (16777216)
*** Check failure stack trace: ***
    @     0x7fc7555375cd  google::LogMessage::Fail()
    @     0x7fc755539433  google::LogMessage::SendToLog()
    @     0x7fc75553715b  google::LogMessage::Flush()
    @     0x7fc755539e1e  google::LogMessageFatal::~LogMessageFatal()
    @     0x7fc755ba71d0  caffe::RecurrentLayer<>::Reshape()
    @     0x7fc755c7665c  caffe::ConvLSTMLayer<>::Reshape()
    @     0x7fc755ced11e  caffe::Net<>::Init()
    @     0x7fc755ceec41  caffe::Net<>::Net()
    @     0x7fc755caed4a  caffe::Solver<>::InitTrainNet()
    @     0x7fc755caf2b7  caffe::Solver<>::Init()
    @     0x7fc755caf64a  caffe::Solver<>::Solver()
    @     0x7fc755ccbb29  caffe::Creator_RMSPropSolver<>()
    @           0x40ad89  train()
    @           0x407704  main
    @     0x7fc753feb830  __libc_start_main
    @           0x407eb9  _start
    @              (nil)  (unknown)
Aborted (core dumped)
agethen commented 6 years ago

Hi ksnzh,

From the error, I would say that your prototxt might have a problem. It is probably the bottom input called "dummy" in the example -- you need to make sure that the number of channels in dummy is the same as for the convlstm layer. Your dataset preparation file looks fine on first glance :)