《TensorFlow机器学习实战指南》学习笔记--1.6.4 延伸学习

找不到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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值