【Tensorflow】module ‘tensorflow‘ has no attribute ‘space_to_depth‘

阅读 90

2022-05-01

问题:

使用tensorflow 2定义模型的时候,提示:

module 'tensorflow' has no attribute 'space_to_depth'

分析:

tensorflow 2中space_to_depth的模块不同于tensorflow 1

解决:

import tensorflow as tf

tensorflow 1.x: tf.space_to_depth
tensorflow 2.x: tf.nn.space_to_depth

或者使用:

import tensorflow.compat.v1 as tf

tf.space_to_depth

精彩评论(0)

0 0 举报