Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Training input dimensions #29

Open
ch3njust1n opened this issue Nov 27, 2016 · 3 comments
Open

Training input dimensions #29

ch3njust1n opened this issue Nov 27, 2016 · 3 comments

Comments

@ch3njust1n
Copy link

ch3njust1n commented Nov 27, 2016

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
Copy link
Owner

Newmu commented Nov 28, 2016

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

@ch3njust1n
Copy link
Author

@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?

@Lucky-Tsang
Copy link

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()`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants