Python 其中一个维度的任意大小

Python 其中一个维度的任意大小,python,keras,Python,Keras,定义自己的生成器函数时,如下所示: def generator(features, labels, batch_size): # Create empty arrays to contain batch of features and labels# batch_features = np.zeros((batch_size, 64, 64, 3)) batch_labels = np.zeros((batch_size,1)) while True: for i in range

定义自己的生成器函数时,如下所示:

def generator(features, labels, batch_size):
 # Create empty arrays to contain batch of features and labels#
 batch_features = np.zeros((batch_size, 64, 64, 3))
 batch_labels = np.zeros((batch_size,1))
 while True:
   for i in range(batch_size):
     # choose random index in features
     index= random.choice(len(features),1)
     batch_features[i] = some_processing(features[index])
     batch_labels[i] = labels[index]
   yield batch_features, batch_labels
是否有办法指定batch_功能中的一个维度是任意的。因此,假设我的批处理大小是32,并且我有10个不同的特性,但是样本数量没有定义。所以我有这样的想法:

np.zeros((32, ,10))
i、 许多样品可以是任何东西。我知道将训练数据传递到keras中的.fit()函数中只会对维度施加约束,而不会对样本数施加约束。不过,我不确定如何修改上述代码,以纳入我的要求

编辑: 因此,我真正感兴趣的是,我是否能创造出这样的形式:

np.array([1,2,3],[[1,2,3],[4,5,6]],[[1,2,3],[4,5,6],[1,2,3],[4,5,6]])

看起来这是不可能的。

一列
np.array
s?:)我应该休息一下。谢谢:)那就行了。
np.array
s的列表怎么样?:)我应该休息一下。谢谢:)那会有用的