-
Notifications
You must be signed in to change notification settings - Fork 35
Description
I want to use gn into CNN , and meet a prolem:
ailed to convert object of type <class 'list'> to Tensor. Contents: [Dimension(None), 2, Dimension(14), Dimension(28), Dimension(32)]. Consider casting elements to a supported type.
this is the code:
def groupnorm(x,gamma,bate,G,eps=1e-5):
x=tf.transpose(x,[0,3,1,2])
N,C,H,W =x.get_shape().as_list()
G=min(G,C)
print('x:',x)
x=tf.reshape(x,[N,G,C//G,H,W])
mean,var = tf.nn.moments(x,[2,3,4],keep_dims=True)
x=(x-mean)/tf.sqrt(var+eps)
gamma=tf.get_variable('gamma',[C],initializer=tf.constant_initializer(1.0))
bate=tf.get_variable('bate',[C],initializer=tf.constant_initializer(1.0))
gamma=tf.reshape(gamma,[1,C,1,1])
bate=tf.reshape(gamma,[1,C,1,1])
x=tf.reshape(x, [N, H, W, C])
output=x*gamma+bate
output=tf.transpose(output,[0,2,3,1])
print('a:',a)
return output