ageron / ageron/handson-ml

chapter-9, Name Scopes valueerror. cannot be interpreted as a Tensor

Open
#489 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Jupyter Notebook
Stars
25.6k
Forks
12.7k
PR merge metrics
No merged PRs in 30d

Description

```
------------------------------------------------------------------------
ValueError Traceback (most recent call last)
~/anaconda3/lib/python3.7/site-packages/tensorflow/python/client/session.py in __init__(self, fetches, contraction_fn)
302 self._unique_fetches.append(ops.get_default_graph().as_graph_element(
--> 303 fetch, allow_tensor=True, allow_operation=True))
304 except TypeError as e:

~/anaconda3/lib/python3.7/site-packages/tensorflow/python/framework/ops.py in as_graph_element(self, obj, allow_tensor, allow_operation)
3795 with self._lock:
-> 3796 return self._as_graph_element_locked(obj, allow_tensor, allow_operation)
3797

~/anaconda3/lib/python3.7/site-packages/tensorflow/python/framework/ops.py in _as_graph_element_locked(self, obj, allow_tensor, allow_operation)
3879 if obj.graph is not self:
-> 3880 raise ValueError("Operation %s is not an element of this graph." % obj)
3881 return obj

ValueError: Operation name: "GradientDescent"
op: "NoOp"
input: "^GradientDescent/update_theta/ApplyGradientDescent"
is not an element of this graph.

During handling of the above exception, another exception occurred:

ValueError Traceback (most recent call last)
in
13 step = epoch * n_batches + batch_index
14 file_writer.add_summary(summary_str, step)
---> 15 sess.run(training_op, feed_dict={X: X_batch, y: y_batch})
16
17 best_theta = theta.eval()

~/anaconda3/lib/python3.7/site-packages/tensorflow/python/client/session.py in run(self, fetches, feed_dict, options, run_metadata)
948 try:
949 result = self._run(None, fetches, feed_dict, options_ptr,
--> 950 run_metadata_ptr)
951 if run_metadata:
952 proto_data = tf_session.TF_GetBuffer(run_metadata_ptr)

~/anaconda3/lib/python3.7/site-packages/tensorflow/python/client/session.py in _run(self, handle, fetches, feed_dict, options, run_metadata)
1156 # Create a fetch handler to take care of the structure of fetches.
1157 fetch_handler = _FetchHandler(
-> 1158 self._graph, fetches, feed_dict_tensor, feed_handles=feed_handles)
1159
1160 # Run request and get response.

~/anaconda3/lib/python3.7/site-packages/tensorflow/python/client/session.py in __init__(self, graph, fetches, feeds, feed_handles)
472 """
473 with graph.as_default():
--> 474 self._fetch_mapper = _FetchMapper.for_fetch(fetches)
475 self._fetches = []
476 self._targets = []

~/anaconda3/lib/python3.7/site-packages/tensorflow/python/client/session.py in for_fetch(fetch)
272 if isinstance(fetch, tensor_type):
273 fetches, contraction_fn = fetch_fn(fetch)
--> 274 return _ElementFetchMapper(fetches, contraction_fn)
275 # Did not find anything.
276 raise TypeError('Fetch argument %r has invalid type %r' % (fetch,

~/anaconda3/lib/python3.7/site-packages/tensorflow/python/client/session.py in __init__(self, fetches, contraction_fn)
308 except ValueError as e:
309 raise ValueError('Fetch argument %r cannot be interpreted as a '
--> 310 'Tensor. (%s)' % (fetch, str(e)))
311 except KeyError as e:
312 raise ValueError('Fetch argument %r cannot be interpreted as a '

ValueError: Fetch argument cannot be interpreted as a Tensor. (Operation name: "GradientDescent"
op: "NoOp"
input: "^GradientDescent/update_theta/ApplyGradientDescent"
is not an element of this graph.)

```
i was reset the previous graph. but it is throwing again for cannot be interpreted as a Tensor

How to resolve this issue sir.

Thank you

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.