tensorlayer / TensorLayer

Deep Learning and Reinforcement Learning Library for Scientists and Engineers
http://tensorlayerx.com
Other
7.33k stars 1.61k forks source link

Spatial Transformer not working #1098

Open gergopool opened 4 years ago

gergopool commented 4 years ago

New Issue Checklist

Issue Description

I was intended to use your SpatialTransformer layer, but it just doesn't work (tensorflow 2.3). First my problem was that the SpatialTransformer2dAffine/forward function returned with a tensor with wrong shape (including Nones), but it could be fixed by changing the line

batch_size = theta_input.shape[0]

to

batch_size = tf.shape(theta_input)[0]

After I fixed this, the python interpreter stopped at tensorlayer.layers.core.Layer/_add_node, because the tensor objects have no _info attribute.

Can you please double-check if your spatial transformer works as intended under tf2? Thanks. ^^

Laicheng0830 commented 4 years ago

' object has no attribute '_info'. check your inputs, the input needs to be Layer; For Your Information:


    from tensorlayer.layers import Input, Flatten, Dense
    ni = Input([32, 40, 40, 1])
    nn = Flatten()(ni)
    nn = Dense(n_units=20, act=tf.nn.tanh)(nn)
    stn = SpatialTransformer2dAffine(out_size=(20, 20), in_channels=20)
    nn = stn((nn, ni))
    print(nn)`