【问题标题】:Visualising np.reshape for TensorFlow为 TensorFlow 可视化 np.reshape
【发布时间】:2016-08-08 19:57:22
【问题描述】:

我有一些数据想输入卷积神经网络。

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_hex_a

我脑海中的画面是,我想输入具有两个通道(一个用于 ex_h 值,一个用于 ex_a 值)的 16x16 图像。

我打电话给np.reshape 是否实现了这一点,我发现很难想象这一点。我也对-1 以及为什么 TensorFlow 需要 4 级张量感到有些困惑。

【问题讨论】:

    标签: numpy tensorflow


    【解决方案1】:

    我认为“np.reshape 实现这一目标”是对的。

    -1 表示第一个维度的大小将自动计算为 total_number_of_elements/16/16/2。

    四个维度分别是:batch_size、height、weight、channels(特征图的个数)。有一个批量大小,因为它使用小批量梯度下降。

    【讨论】:

      猜你喜欢
      • 2018-02-02
      • 2019-02-06
      • 2020-06-04
      • 1970-01-01
      • 2018-12-16
      • 2017-01-14
      • 2017-03-28
      • 1970-01-01
      • 2023-03-29
      相关资源
      最近更新 更多