• Register
0 votes
106 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

Please log in or register to answer this question.

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

0 votes
1 answer 5 views
5 views
Problem: I am trying to create a CNN model with help of the following code: import tensorflow as tf class Create_CNN: def _conv(self, input, nChannels, kernelSize, kernelStride): conv = tf.layers.conv2d(inputs=input, filters=nChannels, kernel_size=kernelSize, strides=(kernelStride, ... not sure what wrong I did. I need to see the logits generated from my CNN model. I really need help on this.
asked Apr 25 Moumita Bhowmick 12.4k points
0 votes
1 answer 3 views
3 views
Problem: I am currently trying to build a naive Bayes classifier. Referring to the line X_new_tfidf = tfidf_transformer.transform(X_new_counts) under the Training the Classifier subheading, I had a similar line, X_new_counts = count_vect.transform(input.plot_movie) in my code which ... that input.plot_movie is of type unicode and decided to convert it to a string. I encounter the same error again.
asked 1 day ago jamuna1 30.2k points
0 votes
1 answer 3 views
3 views
Problem: I am using tensorflow's models. I set up environment by seeing this web site.It was success until Add Libraries to PYTHONPATH. But when I run python object_detection/builders/model_builder_test.py in models/research directory,AttributeError: module 'pandas' has no attribute 'computation' What should I do to fix this?What is wrong in my code?
asked 1 day ago sumaiya simi 43.9k points
0 votes
1 answer 3 views
3 views
Problem: I am using tensorflow's models. I set up environment by seeing this web site. .It was success until Add Libraries to PYTHONPATH. But when I run python object_detection/builders/model_builder_test.py in models/research directory,AttributeError: module 'pandas' has no attribute 'computation'What should I do to fix this?What is wrong in my code?
asked 1 day ago sumaiya simi 43.9k points
0 votes
1 answer 2 views
2 views
Problem: I have build a model with sklearn Naive Bayes classifier. I need to know how to predict a sentence with input when i just hardcode the sentence its work fine, look like this new_sentence = ['its so broken'] new_testdata_tfidf= tfidf.transform(new_sentence) ... predict it. the classificaiton out, the class is -1 which is the correct answer How to resolve this? any help really appreciated.
asked 3 days ago Humaira ahmed 50.7k points
0 votes
1 answer 2 views
2 views
Problem: Every time I try and re-install Cuda it fails and whenever I try and import Tensorflow with the current set up I have it will pip install but it will not import and will instead return: import tensorflow as tf Traceback (most recent call ... load_dynamic return _load(spec) ImportError: DLL load failed: The specified module could not be found. Failed to load the native TensorFlow runtime.
asked Apr 26 ochena 22.1k points
0 votes
0 answers 3 views
3 views
Problem: How is preprocessing method used for unstructured data classification? Give some hints ore example .
asked Apr 28 nabin 4.6k points
0 votes
1 answer 13 views
13 views
Problem: I'm working on my project for a course and I'm totally stuck right now. I'm stuck as I am getting the above error.can anybody help?
asked Mar 24 Sana8989 8.9k points
0 votes
1 answer 17 views
17 views
Problem : InvalidArgumentError: You must feed a value for placeholder tensor
asked Feb 27 Sabbir Hossain 14.6k points
1 vote
2 answers 894 views
894 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, 2020 Kashish