Tensorflow.ipynb--type error when executed


#1

Hi,
I am referring tensorflow.ipynb file. I am trying to run it in cloudxlab. When i run below line of code.

sess = tf.Session()
sess.run(x.initializer)
sess.run(y.initializer)
result = sess.run(f)
print(result)
sess.close()

It is showing type error as below:
TypeError: Fetch argument <_io.TextIOWrapper name=‘simple.txt’ mode=‘r’ encoding=‘UTF-8’> has invalid type <class ‘_io.TextIOWrapper’>, must be a string or Tensor. (Can not convert a TextIOWrapper into a Tensor or Operation.)

can you please help me on how to fix it.


#2

@sandeepgiri, Hi Sandeep,
Sorry for bothering you.

Can you please check what is the issue. I have been waiting for solution for quite long time.

Thanks and Regards
Ganesh


#3

Hi @ganeshkumar_patil

Where did you find this line in the notebook?

Can you please paste some more code?


#4

@abhinav Thanks for reply.

I cloned https://github.com/cloudxlab/ml.git repo and path: deep_learning/Tensorflow.ipynb.

It is 19th run from beginning. I am still getting this error when try to run on cloudxlab environment.

Similar issue with deep_learning/introduction_to_artificial_neural_networks.ipynb file.
28th run on jupyter for below code:
with tf.name_scope(“dnn”):
hidden1 = tf.layers.dense(X, n_hidden1, name=“hidden1”,
activation=tf.nn.relu)
hidden2 = tf.layers.dense(hidden1, n_hidden2, name=“hidden2”,
activation=tf.nn.relu)
logits = tf.layers.dense(hidden2, n_outputs, name=“outputs”)

Also on 41th run on below line of code on deep_learning/introduction_to_artificial_neural_networks.ipynb file:
with tf.name_scope(“loss”):
xentropy = tf.nn.sparse_softmax_cross_entropy_with_logits(labels=y,logits=logits)
loss = tf.reduce_mean(xentropy, name=“loss”)

Thanks and Regards
Ganesh


#5

Just comment out these lines and it should work

with open("simple.txt") as f:
    for line in f:
        print(line)

#6

@abhinav Thank you so much…it worked. But dont know how it is related to above line of code?


#7

Please check the value of “f” and you will come to know why it was creating problem