Madison May
Madison May

Reputation: 2763

Convert CudaNdarraySharedVariable to TensorVariable

I'm trying to convert a pylearn2 GPU model to a CPU compatible version for prediction on a remote server -- how can I convert CudaNdarraySharedVariable's to TensorVariable's to avoid an error calling cuda code on a GPU-less machine? The experimental theano flag unpickle_gpu_to_cpu seems to have left a few CudaNdarraySharedVariable's hanging around (specifically model.layers[n].transformer._W).

Upvotes: 1

Views: 514

Answers (1)

rahulm
rahulm

Reputation: 744

For a plain CudaNdarray variable, something like this should work:

'''x = CudaNdarray... x_new=theano.tensor.TensorVariable(CudaNdarrayType([False] * tensor_dim))
f = theano.function([x_new], x_new)

converted_x = f(x) '''

Upvotes: 1

Related Questions