Skip to content

There is a prolem for running #4

@dddddkkk

Description

@dddddkkk

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions