Reputation: 185
I have a series of 2d arrays which always differ for one dimension size, e.g. (20,87), (20,100), (20,76), etc... Those arrays are composed by Mel-frequency cepstrum coefficients (mfccs) for time steps (times), so (mfccs, times).
In oder to train a CNN in Tensorflow, I need to feed a dictionary with a batch of some of those 2d arrays.
I would like to have a 3d array because my input tensor would be: x=tf.placeholder('float', shape=(n,mfccs, times)), where n is the batch size. So the batch would be a 3d array with this shape: (n,mfccs,times), where only the size of times dimension changes.
I thought also to use a list of 2d arrays instead of a 3d array. But is it possible to feed a list in the feed_dict (e.g. feed_dict={ x: list?})? if yes, how do you do that?
Many thanks for the help in advance.
Upvotes: 1
Views: 557
Reputation: 1978
For different sizes, but acting as an array, one can try list:
a = [[0]*87 for range(20)]
b = [[0]*100 for range(20)]
c = [[0]*76 for range(20)]
big_list = []
big_list.append(a)
big_list.append(b)
big_list.append(c)
After all this, big_list
has length of 3, where each elements contains respective list/array.
Upvotes: 0