Keras"形状必须具有相同的等级"尝试用另一个张量切片张量时出错

时间:2018-06-14 17:05:41

标签: keras

基于我提出的其他一些问题,我试图定义一个自定义丢失函数,它允许我使用另一个张量的内容对输入张量的内容进行切片:

We are sorry, but you do not have access to this service.

我收到以下错误:

def innerLoss(z):
    y_pred = z[0] 
    patch_x = z[1][0]
    patch_y = z[1][1]
    patch_true = y_pred[patch_y:patch_y+10, patch_x:patch_x+10, 0]
    return 0

originalInputs = Input(shape=(128, 128, 1))
featureInputs = Input(shape=(2,), dtype="int64")
originalOutputs = Input(shape=(128, 128, 1))
loss = Lambda(innerLoss)([originalOutputs, featureInputs])
outerModel = Model(inputs=[originalInputs, featureInputs], outputs=loss)

此处,ValueError: Shapes must be equal rank, but are 1 and 0 From merging shape 1 with other shapes. for 'lambda_3/strided_slice_2/stack_1' (op: 'Pack') with input shapes: [2], [2], []. 将包含一对坐标,告诉我们在featureInputs中开始切割图片的位置。

0 个答案:

没有答案