【发布时间】:2020-12-18 15:20:08
【问题描述】:
我有一个尺寸为 100x120x3 的图像。在对原始图像应用卷积后,我想在训练期间从图像中获取一个子集/补丁,大小为 11x11x3。补丁将以索引“index1”和“index2”为中心。我正在尝试的代码写在下面。 feats_new的尺寸与图片相同。
x = Input(shape=(100,120,3), name='inputA')
index1 = Input(shape=(1,), name='ind1', dtype = 'int32')
index2 = Input(shape=(1,), name='ind2', dtype = 'int32')
feats_new = encoder(x)
patch = feats_new[:,index1-5:index1+6, index2-5:index2+6,:]
执行时出现以下错误:
TypeError: Cannot convert a symbolic Keras input/output to a numpy
array. This error may indicate that you are trying to pass a
symbolic value to a NumPy call, which is not supported. Or, you may
be trying to pass Keras symbolic inputs/outputs to a TF API that
does not register dispatching, preventing Keras from automatically
converting the API call to a lambda layer in the Functional Model.
和
ValueError: Shapes must be equal rank, but are 2 and 0
From merging shape 2 with other shapes.
For '{{nodetf.__operators__.getitem_11/strided_slice/stack_2}} =
Pack[N=4, T=DT_INT32, axis=0
(tf.__operators__.getitem_11/strided_slice/stack_2/values_0,
Placeholder_1, Placeholder_3,
tf.__operators__.getitem_11/strided_slice/stack_2/values_3)' with
input shapes: [], [?,1], [?,1], []
如何获得补丁?
【问题讨论】:
标签: tensorflow keras tf.keras