e-lab / ENet-training

351 stars 88 forks source link

Train and use without CUDA! #28

Closed Mina1368 closed 8 years ago

Mina1368 commented 8 years ago

Hi

Is it possible to design encoder and decoder in a way not using CUDA?

Thank You, Mina

codeAC29 commented 8 years ago

Yes, you can replace all cudnn modules with nn modules used in encoder/decoder.lua, get rid of all cuda calls, and then train you network. But it will take really long time to train your network on cpu. Instead you can train it on gpu, then convert this cuda model into nn using cudnn.convert(network, nn) (where network is your trained model), and then further change it into a float type from cuda type by network:float().

Mina1368 commented 8 years ago

Thank you codeA29. I could convert the model, but for the loss, nn module does not have SpatialCrossEntropyCriterion(), instead I used nn.LogSoftMax() and nn.ClassNLLCriterion(). Is that fine? It also needs to convert the model output and target to 1Dimensional. Best, Mina

codeAC29 commented 8 years ago

Trained model does not have any loss or criterion in it. So, you can convert the model without thinking about criterion. In case you are thinking about training a fresh model; different criterion is going to give you different result, but often these results are comparable.

Mina1368 commented 8 years ago

Thank you. I am going to train a new model. I will reduce the batch size so that I can use the GPU I have.