我正在使用tensorflow和numpy,并遇到了一个问题,即在单个测试示例上运行概率_model()。我的数组x_test是2d数组。
probability_model(x_test[:1])
工作正常,但是
probability_model(x_test[0])
返回WARNING:tensorflow:Model was constructed with shape Tensor("sequential_input:0", shape=(None, 28, 28), dtype=float32) for input (None, 28, 28), but it was re-called on a Tensor with incompatible shape (28, 28).
我认为x_test [0]和x_test [:1]将返回相同的1D数组,但是似乎其中一个结果是尺寸为(None,28,28)的数组,另一个结果是(28,28) )数组。所以我的问题不是关于tensorflow(我只是用它来显示我的错误),这些表达式是否实际上导致了不同的数组,如果有的话,这有什么区别,因为在分析它们的输出时它们看起来是相同的。最后,是否有一个表达式可以用来将x_test [0]转换为我需要调用函数的(None,28,28)大小?
谢谢
答案 0 :(得分:2)
一个简单的测试表明,for (const obj of allWebGL2ContextsResources.get(someContext).entries()) {
for (const type of types) {
const Type = `WebGL${type}`;
if (obj instanceof window[Type]) {
someContext[`delete${type}`](obj);
continue;
}
}
}
allWebGL2ContextsResources.delete(someContext);
返回了位于arr[0]
中位置的对象,而0
返回了在索引arr[:1]
处切出的列表(因此只是第一个对象)
1
输出:
a = [1, 2, 3]
print(a[0], a[:1])