2016-11-28 58 views
2

目前(版本0.11.0)tf.nn.crelu()不正确设置静态形状:静态形状

f = tf.random_normal([50, 5, 7, 10]) 
f2 = tf.nn.relu(f) 
print(f2.get_shape().as_list()) # [50, 5, 7, 10] 
f3 = tf.nn.crelu(f) 
print(f3.get_shape().as_list()) # [None, None, None, None] 

with tf.Session() as sess: 
    print(tf.__version__) 
    py_f2, py_f3 = sess.run([f2, f3]) 

这已经提交的Github上issue #5912

回答

2

解决方法:

f = tf.random_normal([50, 5, 7, 10]) 
[b, nx, ny, nz] = f.get_shape().as_list() 
f3 = tf.nn.crelu(f) 
f3.set_shape([b, nx, ny, 2*nz] 
print(f3.get_shape().as_list()) # [50, 5, 7, 20]