problem creating HDF5 for caffe

70 views
Skip to first unread message

Sharp Weapon

unread,
Oct 6, 2016, 2:20:39 PM10/6/16
to Caffe Users
I created HDF5 data using the following python script and placed HDF5 data layer. However, when I tried to train caffe using this data it keeps complaining "...Check failed: num_spatial_axes_ == 2 (0 vs. 2) kernel_h & kernel_w can only be used for 2D convolution"

Here is how my data looks like:

1. Data(1x3000), label(1x128) binary. I sliced the 128 into 16 bytes and translated that to dec to use it as a mulitlabel. So a typical key would look like, (20, 38, 123, 345,...) 1x16. and I have 1,000,000 of data like (1). For now I am just using the first byte, so I will have one integer as a label.

DIR ="/x/"
h5_fn= os.path.join('/x/h5Data_train.h5')
from numpy import genfromtxt  
dim=64000


InputData=np.arange(3253)
data=np.arange(dim*3253)
data.shape=(dim,3253)

fileList=[os.path.join(i) for folder, subdir,files in os.walk(DIR) for i in files]

for i in range(0,len(fileList)):
    InputData=np.genfromtxt(DIR+fileList[i],delimiter=',',skip_header=24)
    data[i]=InputData

label=np.arange(dim)
labelData=np.genfromtxt(DIR+'label_file',comments='\t',dtype=None)

for i in range(0,dim):
    label[i]=int(labelData[i][0:2],16)

print "Creating HDF5..."
with h5py.File(h5_fn,'w') as f:
    f['InputData']=data
    f['label']=label


text_fn=os.path.join('/x/hdf5.txt')
with open(text_fn,'w') as f:
    f.write('h5_fn')

This script creates the HDF5, but I am suspecting that the error from caffe is related to how I created my HDF5 file. Can someone tell me if there is anything wrong on how I created the HDF5. Thanks!

Przemek D

unread,
Oct 7, 2016, 4:47:29 AM10/7/16
to Caffe Users
You'd make it easier for us to help you if you either didn't mix the issues you're having, or post everything (as each of your 3 threads seem to be related) in a single thread.

I replied you in another thread, suggesting you should make your data 3D (so 1x1x3000 instead of 1x3000) to enable convolution. Try and tell us how it worked.
Reply all
Reply to author
Forward
0 new messages