I suspect the place where you copied the code from had eager execution enabled, i.e. had invoked tf.enable_eager_execution()
at the start of the program.
You could do the same.
UPDATE: Note that eager execution is enabled by default in TensorFlow 2.0. So the answer above applies only to TensorFlow 1.x
More Related Contents:
- How to print the value of a Tensor object in TensorFlow?
- Convert a tensor to numpy array in Tensorflow?
- Understanding tensordot
- Using a pre-trained word embedding (word2vec or Glove) in TensorFlow
- TypeError: __array__() takes 1 positional argument but 2 were given (Image classification Keras)
- Conditional assignment of tensor values in TensorFlow
- How to understand the term `tensor` in TensorFlow?
- TensorFlow ValueError: Cannot feed value of shape (64, 64, 3) for Tensor u’Placeholder:0′, which has shape ‘(?, 64, 64, 3)’
- NotImplementedError: Cannot convert a symbolic Tensor (lstm_2/strided_slice:0) to a numpy array. T
- How to get stable results with TensorFlow, setting random seed
- Load numpy array in google-cloud-ml job
- ValueError: Output tensors to a Model must be the output of a TensorFlow `Layer`
- Why is numpy native on M1 Max greatly slower than on old Intel i5?
- surface plots in matplotlib
- How to install python modules without root access?
- Efficient Numpy 2D array construction from 1D array
- Replacing Pandas or Numpy Nan with a None to use with MysqlDB
- Why does pyplot.contour() require Z to be a 2D array?
- Use scipy.integrate.quad to integrate complex numbers
- Custom transformer for sklearn Pipeline that alters both X and y
- Find out if/which BLAS library is used by Numpy
- In Tensorflow, get the names of all the Tensors in a graph
- In TensorFlow, what is the difference between Session.run() and Tensor.eval()?
- Python/Numpy MemoryError
- How to determine whether a column/variable is numeric or not in Pandas/NumPy?
- Why does numpy have a corresponding function for many ndarray methods?
- Python OpenCV2 (cv2) wrapper to get image size?
- Setting the fmt option in numpy.savetxt
- NumPy grouping using itertools.groupby performance
- Determine if an image exists within a larger image, and if so, find it, using Python