大佬教程收集整理的这篇文章主要介绍了即使仅使用浮点数,f-string 中的“ValueError: Precision not allowed in integer format specifier”也会弹出,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在训练神经网络,但这无关紧要。唯一相关的信息是这一行:
print(f"{it*100/iters}%,Pos: ({Xcg:.4},{Ycg:.4}),IDeal position: ({Xcg:.4},{Xcg**2-Xcg:.4}),Rew: {c_reward:.3},Ang: {ang:.3},ε: {self.eps:.3}")
其中 Xcg、Ycg 和 ang 是浮点数(0. 或 0.5-0.5 之类的值,这也是浮点数);
c_reward 是用这个表达式计算的:
r = math.exp(-abs(posy-posx**2+posx))*math.sqrt(posx**2+posy**2)*abs(posx)/posx if posx!= 0 else 0
和 self.eps 是使用这个表达式计算的:
self.eps = 0.8 + 0.8 * math.exp(-0.001 * self.steps)
steps 从 0 到 4000。所以,eps 也是一个浮点数。
这些都不可能是浮点数。这里发生了什么?它也不会在 self.steps 的特定值处发生,现在它看起来是随机的。
我至少可以看到一个 int
而没有看到所有详细信息,您的 else
用于 0
,它是一个 int
。需要为浮点数做 0.0
。
r = math.exp(-abs(posy-posx**2+posx))*math.sqrt(posx**2+posy**2)*abs(posx)/posx if posx!= 0 else 0.0
以上是大佬教程为你收集整理的即使仅使用浮点数,f-string 中的“ValueError: Precision not allowed in integer format specifier”也会弹出全部内容,希望文章能够帮你解决即使仅使用浮点数,f-string 中的“ValueError: Precision not allowed in integer format specifier”也会弹出所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。