1
~\AppData\Roaming\Python\Python36\site-packages\tensorflow\contrib\tpu\python\tpu\tpu_estimator.py in <module>()
     38 from tensorflow.contrib.tpu.python.tpu import tpu_config
     39 from tensorflow.contrib.tpu.python.tpu import tpu_context
---> 40 from tensorflow.contrib.tpu.python.tpu import tpu_feed
     41 from tensorflow.contrib.tpu.python.tpu import training_loop
     42 from tensorflow.contrib.tpu.python.tpu import util as util_lib

~\AppData\Roaming\Python\Python36\site-packages\tensorflow\contrib\tpu\python\tpu\tpu_feed.py in <module>()
     26 from six.moves import xrange  # pylint: disable=redefined-builtin
     27 
---> 28 from tensorflow.compiler.xla.experimental.xla_sharding import xla_sharding
     29 from tensorflow.compiler.xla.python_api import xla_shape
     30 from tensorflow.contrib.tpu.python.ops import tpu_ops

ModuleNotFoundError: No module named 'tensorflow.compiler'

运行以下代码时出现上述错误:env:windows10+jupyter notebook+tensorflow1.9+python3.6

import tensorflow as tf
x_image = tf.reshape(x, [-1,24,24,3])
h_conv1 = tf.contrib.layers.conv2d(x_image, 64,5,1, "SAME", 
activation_fn=tf.nn.relu)
4

2 回答 2

2

如果 Tensorflow 的安装不完整(例如,如果“pip install tensorflow”已被中断,则可能会发生此错误。

于 2019-07-19T10:17:46.107 回答
0

我在 Cloud TPU (ctpu) 机器上使用 Python 3 运行了您的示例,定义x和初始化全局变量如下:

sess = tf.Session()
sess.run(tf.global_variables_initializer())
x = tf.ones(shape=[24*24*3*50], dtype=tf.float32)
x_image = tf.reshape(x, [-1,24,24,3])
h_conv1 = tf.contrib.layers.conv2d(x_image, 64,5,1, "SAME",
                                   activation_fn=tf.nn.relu)
sess.run(h_conv1)

它工作正常。

于 2018-09-27T15:44:09.220 回答