TensorLayer icon indicating copy to clipboard operation
TensorLayer copied to clipboard

Spatial Transformer not working

Open gergopool opened this issue 3 years ago • 1 comments

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. ^^

gergopool avatar Aug 05 '20 12:08 gergopool

' 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)`

Laicheng0830 avatar Aug 06 '20 02:08 Laicheng0830