TypeError: Layer reshape_1 does not support masking, but was passed an input_mask: Tensor("concatena

本文详细探讨了在使用Keras框架时遇到的Reshape层错误,并提供了一个有效的解决方案。通过插入Lambda层,可以避免Reshape层不支持masking的问题。此外,文章邀请读者分享更多关于此问题的操作技巧。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Keras Reshape层报错

Traceback (most recent call last):
    pcsel = Reshape((-1, 20, 30))(pcsel)
  File "/home/xxx/anaconda3/envs/python36/lib/python3.6/site-packages/keras/engine/base_layer.py", line 458, in __call__
    output_mask = self.compute_mask(inputs, previous_mask)
  File "/home/xxx/anaconda3/envs/python36/lib/python3.6/site-packages/keras/engine/base_layer.py", line 616, in compute_mask
    str(mask))
TypeError: Layer reshape_1 does not support masking, but was passed an input_mask: Tensor("concatenate_1/All:0", shape=(?, ?), dtype=bool)

解决方案: 

I found it also works if you insert a Lambda layer before Reshape like this:
x = Lambda(lambda x: x, output_shape=lambda s:s)(x).

But the best thing I guess is to make some operations at this layer. Anyone has a good idea please shows here.

 

参考链接 https://github.com/keras-team/keras/issues/4978 

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值