我有一些数据可以提供给卷积神经网络。
for ranking_list in train:
home_exp = []
away_exp = []
exp = []
home_team = ranking_list[:16]
away_team = ranking_list[16:]
count = 0
for h in home_team:
row_h = []
row_a = []
for a in away_team:
count += 1
ex_h, ex_a = values(h,a)
row_h.append(ex_h)
row_a.append(ex_a)
home_exp+=row_h
away_exp+=row_a
exp = np.array(home_exp + away_exp)
reformatted_training.append(np.reshape(exp, [-1, 16,16,2]))
我有一个排名列表,其中包含32个排名,其中16个与主队相关,16个与客队相关,因此该列表分为两个16个元素列表。
然后,这些排名的每个排列都用于生成两个值ex_h
和ex_a
。
我想到的图片是,我想要提供相当于16x16
图像的两个通道(一个用于ex_h值,一个用于ex_a值)。
我对np.reshape
的调用是否实现了这一点,我发现很难想象这一点。我也对-1
感到有些困惑,为什么TensorFlow需要等级4张量。
答案 0 :(得分:1)
我认为你是对的" np.reshape实现了这个"。
-1表示第一个维度的大小将自动计算为total_number_of_elements / 16/16/2。
四个维度分别为:batch_size,height,weight,channels(feature feature of features feature)。有一个批量大小,因为它使用小批量梯度下降。