1
accuracy = tf.streaming_accuracy (y_pred,y_true,name='acc')
recall = tf.streaming_recall (y_pred,y_true,name='acc')
precision = tf.streaming_precision(y_pred,y_true,name='acc')
confusion = tf.confuson_matrix(Labels, y_pred,num_classes=10,dtype=tf.float32,name='conf')

For the above code, I have received the same error in past few days. Isn't the syntax same as it is in the API documentation for tensorflow?

Łukasz Rogalski
  • 22,092
  • 8
  • 59
  • 93
WiLL_K
  • 575
  • 1
  • 3
  • 22
  • Is your filename named `tensorflow.py`? – Łukasz Rogalski Mar 06 '17 at 14:34
  • Possible duplicate of [Importing installed package from script raises "AttributeError: module has no attribute" or "ImportError: cannot import name"](http://stackoverflow.com/questions/36250353/importing-installed-package-from-script-raises-attributeerror-module-has-no-at) – Łukasz Rogalski Mar 06 '17 at 14:35
  • No! Its no tensorflow.py its autoencoder.py – WiLL_K Mar 06 '17 at 14:35
  • Do you have file named tensorflow.py in same directory as `autoencoder.py`? – Łukasz Rogalski Mar 06 '17 at 14:37
  • I change filenames when I save it. My last file I was working on was Tflearn_encoder.py – WiLL_K Mar 06 '17 at 14:39
  • One more - can you `print(tf.__file__)` just before `accuracy = ...` and copy-paste an output here? – Łukasz Rogalski Mar 06 '17 at 14:42
  • 'C:\Users\Jay\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\__init__.py Traceback (most recent call last): File "autoencoder1.py", line 88, in accuracy = tf.streaming_accuracy (y_pred,y_true,name='acc') AttributeError: module 'tensorflow' has no attribute 'streaming_accuracy' – WiLL_K Mar 06 '17 at 14:45
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/137352/discussion-between-will-k-and-lukasz-rogalski). – WiLL_K Mar 06 '17 at 14:49

1 Answers1

1

try to use this instead (in a fresh python file, I would suggest create a /tmp/temp.py and run that)

from tensorflow.contrib.metrics import streaming_accuracy

and if this doesn't work then

  1. either there is an installation problem (In which case reinstall)
  2. or you are importing the wrong tensorflow module.
Vikash Singh
  • 13,213
  • 8
  • 40
  • 70
  • Yes, this is working for me. But I would like to know why this was the case in the first place? I mean it should have imported the way I was importing it. – WiLL_K Mar 06 '17 at 14:56
  • @WiLL_K You havn't shared your whole code so it's very difficult to say why it didn't work for your case. – Vikash Singh Mar 06 '17 at 14:58
  • @WiLL_K And what you are trying works on most systems so it's most likely that something has gone wrong on your system or you are making a coding mistake. Since my suggestion worked I would say there is a coding mistake somewhere in module naming or something. – Vikash Singh Mar 06 '17 at 15:01
  • Thanks for the advice but I have solved the problem and its working for me. – WiLL_K Mar 07 '17 at 13:28