uoguelph-mlrg / theano_alexnet

Theano-based Alexnet
BSD 3-Clause "New" or "Revised" License
229 stars 115 forks source link

Testing network on CPU #23

Open nguyenminhduc9988 opened 8 years ago

nguyenminhduc9988 commented 8 years ago

Hi, I would like to use the pretrained model to classify some image and I have a CPU only machine. Can you give me some instruction on how to do this.

Thank you

gwding commented 8 years ago

you'll need to modify the ConvPoolLayer in layer.py such that it use the CPU-compatible convolution operation. and you should be able to reuse the alex_net.py with no/minimal modification

nguyenminhduc9988 commented 8 years ago

Thank you for your quick comment. I will try it.

nguyenminhduc9988 commented 8 years ago

How can I only load the model up. The code in the validate suggest to have a dataset. I want to only load the model and input an image into it.

hma02 commented 8 years ago

@ducminhnguyen For computing with CPU, I think you need to run the code with THEANO_FLAGS=mode=FAST_RUN,device=cpu,floatX=float32 python train.py

Follow the link below for Theano comparison on using CPU and GPU: http://deeplearning.net/software/theano/tutorial/using_gpu.html

Currently, a single image reference is not implemented in this code. Only training and validation on a given batch size of images is supported. If you want to do a single image inference, you may want to construct a theano funtion like this:

inference = theano.funciton(x, [y])

where x is the input image batch to the model (batch size=1, may just pass in an image stored in a numpy array of dimension "c01b", b=1), y is the catagorical binary output of the softmax layer.