Newmu/dcgan_code

Training input dimensions

ch3njust1n opened this issue · 3 comments

I'm trying to create my own dataset. What's the order of the dimensions of the input tensor? Is it (batch_size, channels, height, width), (batch_size, height, width, channels), (batch_size, height * width * channels, 1), or something different? I'm having a lot of trouble creating the hdf5 file. Anyone else have any luck?

Newmu commented

format is (batch, channel, height, width) also called bc01 in theano docs.

@Newmu
If I follow the example (http://fuel.readthedocs.io/en/latest/h5py_dataset.html) for creating a HDF5 dataset, will that do the trick for training on new data or are there other things I should be aware of?

Let me add a little more, though several years passed,wish it can help someone .
When you create the hdf5 ,the dimensions format should be (batch , height , width , channel) .
And before you use it for trainning, it will be converted to (batch,channel,height,width) after the transform function worked .
Next is a small example:
`import h5py
import numpy as np
import matplotlib.pyplot as plt

img_path1 = "../image/1.jpg"
img_path2= "../image/2.jpg"
img_1 = plt.imread(img_path1)#format:[height,width,channel]
img_2 = plt.imread(img_path2)
img=np.stack([img_1,img_2])

f = h5py.File('../hdf5/dataset.hdf5', mode='w')
image_features = f.create_dataset(
'image_features', (2, 64, 64, 3), dtype='uint8')

image_features.dims[0].label = 'batch'
image_features.dims[1].label = 'height'
image_features.dims[2].label = 'width'
image_features.dims[3].label = 'channel'
f.flush()
f.close()`