TF2 使用TPU Compilation failure: Dynamic dimension propagation on reversed dimension is not supported

在TensorFlow2中使用TPU进行训练时遇到动态维度传播不支持的错误,具体表现为`UnimplementedError`,指出在反转维度上的动态维度传播不被支持。解决方案是检查数据集,发现第一维`batch_size`为None,这意味着在TPU环境中,`tf.data.Dataset.batch()`的`drop_remainder`选项必须设为True,以确保batch_size固定,从而解决TPU编译失败的问题。
摘要由CSDN通过智能技术生成

 

在tensorflow2下使用TPU训练时

...

tf.pad(inputs, [[0, 0], [10, 10], [10, 10], [0, 0]], mode='reflect') 

...

batch_size = 1 * tpu_strategy.num_replicas_in_sync
data_set = tf.data.Dataset.from_tensor_slices(X_data) # X_data is a numpy Array
data_set.batch(batch_size)

...

model.fit(data_set, epochs=1)

出现以下错误: 

UnimplementedError: { {function_node __inference_train_function_18379}} Compilation failure: Dynamic dimension propagation on reversed dimension is not supported %reverse.1029 = f32[<=2,276,276,3]{3,2,1,0} reverse(f32[<=2,276,276,3]{3,2,1,0} %concatenate.1028), dimensions={0}, metadata={op_type="MirrorPad" op_name="style_transfer_net/tf_op_layer_MirrorPad/MirrorPad"}
    TPU compilation failed
     [[{ {node tpu_compile_succeeded_assert/_9843984394415337403/_4}}]]

<
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值