mxnet icon indicating copy to clipboard operation
mxnet copied to clipboard

Periodic Loss Value when training with "step" learning rate policy

Open MDR-EX1000 opened this issue 9 years ago • 2 comments

When training deep CNN, a common way is to use SGD with momentum with a "step" learning rate policy(e.g. learning rate set to be 0.1,0.01,0.001.. at different stages of training).But I encounter an unexpected phenomenon when training with this strategy under MXNet.

That is the periodic training loss value image The above is the training loss at a fixed learning rate 0.01, where the loss is decreasing normally image However, at the second stage of training(with lr 0.001) , the loss goes up and down periodically, and the period is exactly an epoch

So I thought it might be the problem of data shuffling, but it cannot explain why it doesn't happen in the first stage. Actually I used ImageRecordIter as the DataIter and reset it after every epoch, is there anything I missed or set mistakenly

train_iter = mx.io.ImageRecordIter(
	path_imgrec=recPath,
	data_shape=dataShape,
	batch_size=batchSize,
	last_batch_handle='discard',
	shuffle=True,
	rand_crop=True,
	rand_mirror=True)

The codes for training and loss evaluation

while True:
	train_iter.reset()
	for i,databatch in enumerate(train_iter):
                globalIter += 1
		mod.forward(databatch,is_train=True)
		mod.update_metric(metric,databatch.label)
		if globalIter % 100 == 0:
                    loss = metric.get()[1]
                    metric.reset()
                mod.backward()
                mod.update()

Actually the loss can converge, but it takes too long. I've suffered from this problem for a long period of time, on different network and different datasets. I didn't have this problem when using Caffe. Is this due to the implementation difference?

Anyone can give some suggestions?

MDR-EX1000 avatar Oct 09 '17 07:10 MDR-EX1000

I found my training loss has the same problem: When the training step into a new epoch, the loss goes down abruptly, then goes up gradually in this epoch. Dose anyone know why it happens?

cccorn avatar Jul 02 '18 08:07 cccorn

I have the same problem

denemmy avatar Sep 28 '18 06:09 denemmy