I am running the below code. I am getting the XLA Compiler error as mentioned below. I am having Tensorflow GPU 1.8 version, but I did try with CPU version and I was getting the error. But when I downgraded Tensorflow (CPU) to 1.3 I was not getting any error. Tensorflow has been installed using virtual environment with Pip.
Please can somebody help me in this.
Code:
import tensorflow as tf
input_tensor = tf.placeholder(dtype=tf.float32, shape=[None, 16, 16, 3])
print(input_tensor.shape)
conv_filter = tf.get_variable('conv_filter', shape=[2, 2, 3, 6], dtype=tf.float32)
conv1 = tf.nn.conv2d(input_tensor, conv_filter, strides=[1, 2, 2, 1], padding='SAME')
print(conv1.shape)
deconv_filter = tf.get_variable('deconv_filter', shape=[2, 2, 6, 3], dtype=tf.float32)
deconv = tf.nn.conv2d_transpose(input_tensor, filter=deconv_filter,
output_shape=tf.shape(input_tensor),
strides=[1, 2, 2, 1],
padding='SAME')
print(deconv.shape)
t = tf.reduce_mean(deconv)
g = tf.train.AdamOptimizer(0.01).minimize(t)
Error log:
(?, 16, 16, 3)
(?, 8, 8, 6)
(?, 16, 16, 3) # <<<<< This should have printed (?, ?, ?, ?)
Traceback (most recent call last):
File "/my/path/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 2327, in get_attr
c_api.TF_OperationGetAttrValueProto(self._c_op, name, buf)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Operation 'conv2d_transpose' has no attr named '_XlaCompile'.
Traceback (most recent call last):
File "/my/path/lib/python3.6/site-packages/tensorflow/python/ops/gradients_impl.py", line 380, in _MaybeCompile
xla_compile = op.get_attr("_XlaCompile")
File "/my/path/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 2331, in get_attr
raise ValueError(str(e))
ValueError: Operation 'conv2d_transpose' has no attr named '_XlaCompile'.
The error is coming in the line g = tf.train.AdamOptimizer(0.01).minimize(t)
The problem is happening because of mismatch in the shape of filter and strides associated with it to produce the required output shape with VALID padding. I should have set deconvolution filter shape of [1, 1, 3, 3] and strides at [1, 1, 1, 1].
Required Code:
deconv_filter = tf.get_variable('deconv_filter', shape=[1, 1, 6, 3], dtype=tf.float32)
deconv = tf.nn.conv2d_transpose(input_tensor, filter=deconv_filter,
output_shape=tf.shape(input_tensor),
strides=[1, 1, 1, 1],
padding='VALID')