1
我刚刚开始学习cntk。但是,我有一个基本问题阻碍了我的进步。我有以下的测试通过:为什么不一致的形状numpy vs cntk?
import numpy as np
from cntk import input_variable, plus
def test_simple(self):
x_input = np.asarray([[1, 2, 2]], dtype=np.int64)
assert (1, 3) == x_input.shape
y_input = np.asarray([[5, 3, 3]], dtype=np.int64)
assert (1, 3) == y_input.shape
x = input_variable(x_input.shape[1])
assert (3,) == x.shape
y = input_variable(y_input.shape[1])
assert (3,) == y.shape
x_plus_y = plus(x, y)
assert (3,) == x_plus_y.shape
res = x_plus_y.eval({x: x_input, y: y_input})
assert 6 == res[0, 0, 0]
assert 5 == res[0, 0, 1]
assert 5 == res[0, 0, 2]
据我所知,输出的形状为(1,1,3)作为第一和第二轴线是分批和分别缺省的动态轴。
但是,为什么我需要将输入变量的形状设置为(3,)而不是(1,3)。使用(1,3)失败。
为什么图中输入节点的形状与用作该节点输入的numpy数据之间存在不一致?
谢谢 水稻