简体   繁体   English

Tensorflow NN 输入维度

[英]Tensorflow NN input dimensions

I have an array with a shape of (8, 8, 2) and would like to train a NN on the array.我有一个形状为 (8, 8, 2) 的数组,并且想在该数组上训练一个 NN。 I would like to add one other integer to the training data like so: [array, int] but then end up with a shape like (2,) which I am unable to train with.我想将另一个整数添加到训练数据中,如下所示: [array, int] 但最终得到一个像 (2,) 这样的形状,我无法用它来训练。 Is there a way that I can create an array that TensorFlow would accept or train the NN with this new array?有没有一种方法可以创建一个数组,TensorFlow 会接受或使用这个新数组训练 NN?

I have tried just making the integer into a vector and adding it onto the array which gives a shape of (9, 8, 2), but that results in a lot of redundant information.我曾尝试将整数变成一个向量并将其添加到数组中,该数组给出了 (9, 8, 2) 的形状,但这会导致大量冗余信息。

my_array = [[(rook, b), (horse, b), (bishop, b), (queen, b), (king, b), (bishop, b), (horse, b), (rook, b)],
                       [(pawn, b) for i in range(8)],
                       [(0, 0) for i in range(8)],
                       [(0, 0) for i in range(8)],
                       [(0, 0) for i in range(8)],
                       [(0, 0) for i in range(8)],
                       [(pawn, w) for i in range(8)],
                       [(rook, w), (horse, w), (bishop, w), (queen, w), (king, w), (bishop, w), (horse, w), (rook, w)]]


my_int = 1

I_tried = my_array+[[(my_int, my_int) for i in range(8)]]

print(numpy.array(my_array).shape) # --> (8, 8, 2)
print(numpy.array(I_tried).shape) # --> (2,)

You may want to use tuples instead of lists then.那么您可能想要使用元组而不是列表。 Depending on the purpose of this concatenation.取决于此串联的目的。 But you can try this:但是你可以试试这个:

my_int = 1
second_array = [(my_int, my_int) for i in range(8)]

I_tried = (my_array, second_array)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM