• Register
0 votes
62 views

Problem :

I am currently working on the TensorFlow that uses very "weird" format of uploading the data. I am trying to to use the NumPy or pandas format for the data to be uploaded, to compare it with scikit-learn results.Also I am getting the digit recognition data from the Kaggle.

But facing following error:

---------------------------------------------------------------------------

FailedPreconditionError                   Traceback (most recent call last)
<ipython-input-82-967faab7d494> in <module>()
      7     Target_batch = np.array(OHTarget[i*50:i*50+50].values)
      8     Target_batch = np.multiply(Target_batch, 1.0 / 255.0)
----> 9     train_step.run(feed_dict={x: batch, y_: Target_batch})
/Users/alecxe/anaconda/lib/python2.7/site-packages/tensorflow/python/framework/ops.pyc in run(self, feed_dict, session)
   2265   none, the default session will be used.
   2266     """
-> 2267  _run_using_default_session(self, feed_dict, self.graph, session)
   2268
   2269
/Users/alecxe/anaconda/lib/python2.7/site-packages/tensorflow/python/framework/ops.pyc in _run_using_default_session(operation, feed_dict, graph, session)
   3761   "the operation's graph is different from the session's "
   3762   "graph.")
-> 3763   session.run(operation, feed_dict)
   3764
   3765
/Users/alecxe/anaconda/lib/python2.7/site-packages/tensorflow/python/client/session.pyc in run(self, fetches, feed_dict)
    443
    444     # Run request and get response.
--> 445     results = self._do_run(target_list, unique_fetch_targets, feed_dict_string)
    446
    447     # User may have fetched the same tensor multiple times, but we
/Users/alecxe/anaconda/lib/python2.7/site-packages/tensorflow/python/client/session.pyc in _do_run(self, target_list, fetch_list, feed_dict)
    517      # pylint: disable=protected-access
    518      raise errors._make_specific_exception(node_def, op, e.error_message,
--> 519                                               e.code)
    520     # pylint: enable=protected-access
    521    raise e_type, e_value, e_traceback
FailedPreconditionError: Attempting to use uninitialized value Variable_1
     [[Node: gradients/add_grad/Shape_1 = Shape[T=DT_FLOAT, _device="/job:localhost/replica:0/task:0/cpu:0"](Variable_1)]]
6 5 3
7,540 points

1 Answer

0 votes

Solution :

Please note the tf.initialize_all_variables() is currently deprecated. So please initialize the tensorflow variables with following code:

tf.global_variables_initializer()

Please find following the sample usage is:

with tf.Session() as sess:

sess.run(tf.global_variables_initializer())

It will surely solve your issue.

9 7 4
38,600 points

Related questions

1 vote
2 answers 196 views
196 views
Anyone aware of this error. I am facing this issue in this function. It is not going to IF statement where I put my filter condition which is true then simply raise Error and without IF it is working but I want to put the filter condition which checks date between ... "value"]) It is not going to IF statement where I put my filter condition which is true then simply raise Error. Any suggestion?
asked May 8 Kashish
1 vote
2 answers 679 views
679 views
Problem : I am receiveing error as the truth value of a dataframe is ambiguous. use a.empty, a.bool(), a.item(), a.any() or a.all().
asked Nov 11, 2019 peterlaw 6.9k points
0 votes
2 answers 497 views
497 views
Problem : I am new to RandomForest model. While predicting my test data using the RandomForest model I am often facing below ValueError. &ldquo;Input contains nan, infinity or a value too large for dtype('float64')&rdquo; I have spent more than two days on the above error but I am unable to fix above error. Can somebody help me in fixing above error?
asked Feb 24 mphil 2.3k points
1 vote
1 answer 148 views
148 views
Problem : I am very new to Python. While trying to execute my code I am facing below warning C:\Python27\lib\site-packages\pandas\core\indexing.py:411: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer ... '] = mydf.review_text.map(lambda x: tokenizer.tokenize(x)) print mydf[:3] I am looking for expert help to fix above error.
asked Apr 27 stewart 4k points
0 votes
0 answers 46 views
46 views
import cv2, time, pandas import numpy as np from termcolor import colored import datetime import pandas as pd import matplotlib.pyplot as plt import os import pyautogui from bokeh.plotting import figure, show, output_file from bokeh.models import HoverTool, ColumnDataSource first_frame = None ... ).strftime("%Y-%m-%d_%H%M%S")+".html") show(p) #plt.savefig('plot.pdf', dpi=300, bbox_inches='tight')
asked Jun 13 Shivi Trivedi