spatial-transformer-network icon indicating copy to clipboard operation
spatial-transformer-network copied to clipboard

The training does not converge

Open cactuslei opened this issue 7 years ago • 10 comments

Hi, thanks a lot for your great work, your code is very clear and easy to understand.

However, when I train with your main.py, the network does not converge. The only change is that I set "SAMPLE" from True to False, since if True, then only 500 samples are used for training. However, the training loss always be around 2.3 and the training is terminated because there is no improvement after 1000 steps. Could you tell me your best accuracy achieved with your code? Thanks a lot.

cactuslei avatar Feb 23 '18 14:02 cactuslei

me too

jacobunderlinebenseal avatar Mar 19 '18 10:03 jacobunderlinebenseal

me too, and all of the images in samples are empty

bit1002lst avatar Apr 11 '18 03:04 bit1002lst

Hey guys, I'll take a look at the code when I get the time.

kevinzakka avatar Apr 18 '18 07:04 kevinzakka

I have the same issue. Looks like it is related to the initialization of the conv and fc layers. I tried only using fc layers for regression and the training converged. Remember to initialize the weight to zeros and bias to identity.

Haven't figured out how to initialize conv layers yet. If anyone make progress on this please let us know.

moormoon avatar Apr 30 '18 02:04 moormoon

i think that the bilinear interpolation process in funtion bilinear_sampler is wrong, and a good example of this process can be found in https://github.com/tensorflow/models/tree/master/research/transformer ` # get pixel value at corner coords Ia = get_pixel_value(img, x0, y0) Ib = get_pixel_value(img, x0, y1) Ic = get_pixel_value(img, x1, y0) Id = get_pixel_value(img, x1, y1)

# recast as float for delta calculation
x0 = tf.cast(x0, 'float32')
x1 = tf.cast(x1, 'float32')
y0 = tf.cast(y0, 'float32')
y1 = tf.cast(y1, 'float32')

# calculate deltas
wa = (x1-x) * (y1-y)
wb = (x1-x) * (y-y0)
wc = (x-x0) * (y1-y)
wd = (x-x0) * (y-y0)

# add dimension for addition
wa = tf.expand_dims(wa, axis=3)
wb = tf.expand_dims(wb, axis=3)
wc = tf.expand_dims(wc, axis=3)
wd = tf.expand_dims(wd, axis=3)

# compute output
out = tf.add_n([wa*Ia, wb*Ib, wc*Ic, wd*Id])`

BlueWinters avatar May 02 '18 12:05 BlueWinters

me too

lifan9880 avatar Nov 02 '18 02:11 lifan9880

how to start the training?

kakashi571 avatar Mar 27 '19 12:03 kakashi571

如何开始培训?

Excuse me,do you know how to train now?

wanziz avatar Aug 22 '19 01:08 wanziz

Excuse me, I would like to know how to start training the model?thank you!

wanziz avatar Aug 22 '19 01:08 wanziz

I think the problem is the gradients of bilinear sampling can not be auto-generated by tensorflow properly. In the original paper, author defined special gradients during this process, and this package has not included it for now.

turandai avatar Nov 17 '21 05:11 turandai