tf.constant() has no keyword "axis" in precision.py
peter-doggart opened this issue · comments
Peter Doggart commented
When I'm running model.calibrate()
using matcher="match_majority_vote"
and k=5
, I get a TypeError
from precision.py
.
x_cal_data, y_cal = train_ds.get_slice(begin=0, size=1000)
calibration = model.calibrate(
x_cal_data,
y_cal,
calibration_metric="f1",
matcher="match_majority_vote",#"match_nearest",
extra_metrics=["precision", "recall", "binary_accuracy"],
verbose=1,
k=5
)
<Huge stack trace>
---> 87 initial_precision = tf.constant([tf.constant([1.0]), tf.zeros(len(p) - 1)], axis=0)
88 p = p + initial_precision
90 return p
TypeError: constant() got an unexpected keyword argument 'axis'
The bit of code in question is:
# If all queries return empty result sets we have a recall of zero. In
# this case the precision should be 1.0 (see
# https://nlp.stanford.edu/IR-book/html/htmledition/evaluation-of-ranked-retrieval-results-1.html#fig:precision-recall).
# The following accounts for the and sets the first precision value to
# 1.0 if the first recall and precision are both zero.
if (tp + fp)[0] == 0.0 and len(p) > 1:
initial_precision = tf.constant([tf.constant([1.0]), tf.zeros(len(p) - 1)], axis=0)
p = p + initial_precision
return p
Looking at the tf.constant() docs there is no axis
argument:
tf.constant(
value, dtype=None, shape=None, name='Const'
)
Is this a bug, or am I missing something? I'm not overly familiar with the internal TF types. More than happy to put in a PR to fix if it is a bug!
Owen Vallis commented
Thanks for raising this and to @abhisharsinha for pushing a fix. I'll cherry pick this from dev and merge it to master.
Owen Vallis commented
Patch available in v0.16.8