TypeError: Cannot iterate over a scalar tensor.
Two tensor scalars are input for plt.bar() for the (x, y) values. (Converting CamDavidsonPilon Bayesian-Hackers to tensorflow2.0)
This is specifically for the "def plot_artificial_sms_dataset():" function. I tried in the code block above and it works if I cast the tensors to int32. Not sure why the solution is variable
link: https://github.com/CamDavidsonPilon/Probabilistic-Programming-and-Bayesian-Methods-for-Hackers/blob/master/Chapter2_MorePyMC/Ch2_MorePyMC_TFP.ipynb
The workaround I found is to convert both into np.array() format. i.e. np.array(x), np.array(y).
Is there another work around within tensorflow2.0? Is there another obvious solution?
plt.bar(days_range, data, color=TFColor[3])
plt.bar(tau - 1, data[tau - 1], color="r", label="user behaviour changed")
plt.xlim(0, 80);
The problem line is the one with (tau - 1). Not sure why the other one doesn't break when it is also using tensors.
My solution:
plt.bar(days_range, data, color=TFColor[3])
plt.bar(np.array(tau - 1), np.array(data[tau - 1]), color="r", label="user behaviour changed")
plt.xlim(0, 80);
x.numpy(), y.numpy() converts 'x' and a 'y' to numpy arrays
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With