Issue
I am trying to replicate the code I found at this page but I am getting the following error:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-21-ac81ef861a8b> in <module>
----> 1 train_and_evaluate(classifier)
<ipython-input-20-6a44bf8c2962> in train_and_evaluate(classifier)
12 tf.reset_default_graph()
13 # Add a PR summary in addition to the summaries that the classifier writes
---> 14 pr = summary_lib.pr_curve('precision_recall', predictions=predictions, labels=y_test.astype(bool), num_thresholds=21)
15 with tf.Session() as sess:
16 writer = tf.summary.FileWriter(os.path.join(classifier.model_dir, 'eval'), sess.graph)
AttributeError: module 'tensorboard.summary' has no attribute 'pr_curve'
---------------------------------------------------------------------------
I am currently using:
- Windows 10 21H1
- python 3.6
- Tensorflow 1.15.0
- Tensorflow-Estimator 1.15.1
- Tensorboard 2.5.0
Should I install an older version of tensorboard?
Solution
Tensorlfow 1.15.0 has attribute summary_lib.pr_curve
.
Take a look at right configurations
keras-applications-1.0.8
tensorboard-1.15.0
tensorflow-1.15.0 tensorflow-estimator-1.15.1
Working sample code
from tensorboard import summary as summary_lib
import tensorflow as tf
labels = tf.constant([False, True, True, False, True], dtype=tf.bool)
predictions = tf.random_uniform(labels.get_shape(), maxval=1.0)
summary_lib.pr_curve(name='foo',
predictions=predictions,
labels=labels,
num_thresholds=11)
merged_summary = tf.summary.merge_all()
with tf.Session() as sess:
writer = tf.summary.FileWriter('/tmp/logdir', sess.graph)
for step in range(43):
writer.add_summary(sess.run(merged_summary), global_step=step)
Answered By - TFer
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.