找不到tf.sub函数
# 自定义函数3x^2 - x + 10
def custom_polynomial(value):
return (tf.sub(3 * tf.square(value), value) + 10)
报错:
2019-04-05 22:27:56.753660: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
2019-04-05 22:27:57.039490: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1432] Found device 0 with properties:
name: GeForce GTX 650 major: 3 minor: 0 memoryClockRate(GHz): 1.1105
pciBusID: 0000:05:00.0
totalMemory: 1.00GiB freeMemory: 834.65MiB
2019-04-05 22:27:57.039841: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1482] Ignoring visible gpu device (device: 0, name: GeForce GTX 650, pci bus id: 0000:05:00.0, compute capability: 3.0) with Cuda compute capability 3.0. The minimum required Cuda capability is 3.7.
2019-04-05 22:27:57.040420: I tensorflow/core/common_runtime/gpu/gpu_device.cc:982] Device interconnect StreamExecutor with strength 1 edge matrix:
2019-04-05 22:27:57.040761: I tensorflow/core/common_runtime/gpu/gpu_device.cc:988] 0
2019-04-05 22:27:57.041131: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1001] 0: N
Traceback (most recent call last):
File "1.6.4-custom_function.py", line 11, in <module>
print(sess.run(custom_polynomial(11)))
File "1.6.4-custom_function.py", line 9, in custom_polynomial
return (tf.sub(3 * tf.square(value), value) + 10)
AttributeError: module 'tensorflow' has no attribute 'sub'
原因
接口变化,把tf.sub已经改成了tf.subtract
参考
[1]部分借口变化
[2]修改后的代码-github