Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/349.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python TypeError:获取参数None的类型无效<;类型';非类型'&燃气轮机;_Python_Tensorflow_Gradient_Floor - Fatal编程技术网

Python TypeError:获取参数None的类型无效<;类型';非类型'&燃气轮机;

Python TypeError:获取参数None的类型无效<;类型';非类型'&燃气轮机;,python,tensorflow,gradient,floor,Python,Tensorflow,Gradient,Floor,我遇到一个错误,代码如下。我想检查功能楼层的坡度,出现错误: import numpy as np import tensorflow as tf def floor(x): return tf.floor(x) # code w1 = tf.Variable([[1.5, 0.5, -0.5, -1.5]]) res = floor(w1) grads = tf.gradients(res, [w1]) with tf.Session() as sess: tf.glo

我遇到一个错误,代码如下。我想检查功能楼层的坡度,出现错误:

import numpy as np
import tensorflow as tf

def floor(x):
    return tf.floor(x)

# code
w1 = tf.Variable([[1.5, 0.5, -0.5, -1.5]])
res = floor(w1)

grads = tf.gradients(res, [w1])

with tf.Session() as sess:
    tf.global_variables_initializer().run()
    print(sess.run(grads))

TensorFlow中
floor()
函数的梯度定义为返回
None
,因为⌊x⌋ 到处都是0(整数除外),因此这允许后端代码将其视为没有连接

有关git问题,请参阅