Tensorflow Typeerror: Fetch Argument None Has Invalid Type
Solution 1:
The problem is that the y_out
argument to sess.run()
is None
, whereas it must be a tf.Tensor
(or tensor-like object, such as a tf.Variable
) or a tf.Operation
.
In your example, y_out
is defined by the following code:
# define modeldef complex_model(X,y,is_training):
pass
y_out =complex_model(X,y,is_training)
complex_model()
doesn't return a value, so y_out = complex_model(...)
will set y_out
to None
. I'm not sure if this function is representative of your real code, but it's possible that your real complex_model()
function is also missing a return
statement.
Solution 2:
I believe that mrry is right.
If you give a second look the the notebook Assignment 2 - Tensorflow.ipynb, you will notice the description cell as follows :
Training a specific model
In this section, we're going to specify a model for you to construct. The goal here isn't to get good performance (that'll be next), but instead to get comfortable with understanding the TensorFlow documentation and configuring your own model.
Using the code provided above as guidance, and using the following TensorFlow documentation, specify a model with the following architecture:
7x7 Convolutional Layer with32 filters and stride of 1 ReLU Activation Layer Spatial Batch Normalization Layer (trainable parameters, with scale and centering) 2x2 Max Pooling layer with a stride of 2 Affine layer with1024 output units ReLU Activation Layer Affine layer from1024input units to 10 outputs
Which is asking you to define a model inside the function
# define modeldefcomplex_model(X,y,is_training):
pass
Just like they did in
def simple_model(X,y):
# define our weights (e.g. init_two_layer_convnet)
# setup variables
Wconv1 = tf.get_variable("Wconv1", shape=[7, 7, 3, 32])
bconv1 = tf.get_variable("bconv1", shape=[32])
W1 = tf.get_variable("W1", shape=[5408, 10])
b1 = tf.get_variable("b1", shape=[10])
# define our graph (e.g. two_layer_convnet)
a1 = tf.nn.conv2d(X, Wconv1, strides=[1,2,2,1], padding='VALID') + bconv1
h1 = tf.nn.relu(a1)
h1_flat = tf.reshape(h1,[-1,5408])
y_out = tf.matmul(h1_flat,W1) + b1
return y_out
Hope this helps!
Post a Comment for "Tensorflow Typeerror: Fetch Argument None Has Invalid Type"