[theano-users] How to set the neural network weights and biases manually?

2017-01-28 Thread chathu matharage
I'm training convolution neural network using firefly algorithm. Although I 
update the weights of the network they seems not updated. So how to update 
the network weights manually?
This is how I update the weights

def set_params(params, bestSolution, layers=[layer0, layer1, layer2, 
layer21, layer3]):
# print('Best sol: ', bestSolution)
# print('params: ', params)

l0w = bestSolution[0:150]
l0b = bestSolution[150:156]
l1w = bestSolution[156:2556]
l1b = bestSolution[2556:2572]
l2w = bestSolution[2572:33292]
l2b = bestSolution[33292:33412]
l21w = bestSolution[33412:43492]
l21b = bestSolution[43492:43576]
l3w = bestSolution[43576:44416]
l3b = bestSolution[44416:44426]


# first conpool layer weights
params[8] = theano.shared(
numpy.reshape(numpy.asarray(l0w, dtype=theano.config.floatX), (6, 
1, 5, 5)),
borrow=True
)
layers[0].params[0] = params[8]
# print('before: ')
# layers[0].ppp()
layers[0].W = params[8]
# print('after: ')
# layers[0].ppp()



# first conpool layer biases
params[9] = theano.shared(numpy.reshape(numpy.asarray(l0b, 
dtype=theano.config.floatX), (6)), borrow=True)
layers[0].params[1] = params[9]
layers[0].b = params[9]

# second conpool layer weights
params[6] = theano.shared(
numpy.reshape(numpy.asarray(l1w, dtype=theano.config.floatX), (16, 
6, 5, 5)),
borrow=True
)
layers[1].params[0] = params[6]
layers[1].W = params[6]

# second conpool layer biases
params[7] = theano.shared(numpy.reshape(numpy.asarray(l1b, 
dtype=theano.config.floatX), (16)), borrow=True)
layers[1].params[1] = params[7]
layers[1].b = params[7]

# first hidden layer weights
params[4] = theano.shared(numpy.reshape(numpy.asarray(l2w, 
dtype=theano.config.floatX), (256, 120)), name='W',
  borrow=True)
layers[2].params[0] = params[4]
layers[2].W = params[4]

# first hidden layer biases
params[5] = theano.shared(numpy.reshape(numpy.array(l2b, 
dtype=theano.config.floatX), (120)), name='b', borrow=True)
layers[2].params[1] = params[5]
layers[2].b = params[5]

# second hidden layer weights
params[2] = theano.shared(numpy.reshape(numpy.asarray(l21w, 
dtype=theano.config.floatX), (120, 84)), name='W',
  borrow=True)
layers[3].params[0] = params[2]
layers[3].W = params[2]

# second hidden layer biases
params[3] = theano.shared(numpy.reshape(numpy.asarray(l21b, 
dtype=theano.config.floatX), (84)), name='b',
  borrow=True)
layers[3].params[1] = params[3]
layers[3].b = params[3]

# output layer weights
params[0] = theano.shared(
numpy.reshape(numpy.asarray(l3w, dtype=theano.config.floatX), (84, 
10)),
name='W',
borrow=True
)
layers[4].params[0] = params[0]
layers[4].W = params[0]

# output layer biases
params[1] = theano.shared(
numpy.reshape(numpy.asarray(l3b, dtype=theano.config.floatX), (10)),
name='b',
borrow=True
)
layers[4].params[1] = params[1]
layers[4].b = params[1]

firefly = params[0] + params[1] + params[2] + params[3] + params[4] + 
 params[5] +  params[6] +  params[7] +  params[8] +  params[9]
return firefly

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"theano-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to theano-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [theano-users] Re: How to get the value of theano tensor variable

2017-01-28 Thread chathu matharage
Thank you very much. I got the value of the variable by using Theano 
function. Do you know how to save the convolution neural network model in a 
pickle file while the network is training? Because I need the model to 
predict new inputs.

On Sunday, January 29, 2017 at 2:02:52 AM UTC+5:30, Jesse Livezey wrote:
>
> Did it give an error? If you're debugging things, eval is the right 
> function to use. If you're outputting the value of these variables during 
> training, you can just add them to the list of outputs when you create the 
> theano function.
>
> On Fri, Jan 27, 2017 at 8:49 PM chathu matharage  > wrote:
>
>> I need to get the value of Elementwise{tanh,no_inplace}.0 variable which 
>> is the output of error of logistic regression layer in convolution neural 
>> network. I tried with eval(). But it didn't work. Is there a method to get 
>> the error value of this type of variable? 
>>
>>
>> On Saturday, January 28, 2017 at 6:27:24 AM UTC+5:30, Jesse Livezey wrote:
>>>
>>> You can use eval
>>>
>>> http://deeplearning.net/software/theano/library/gof/graph.html#theano.gof.graph.Variable.eval
>>>
>>> On Friday, January 27, 2017 at 4:39:56 PM UTC-8, chathu matharage wrote:

 Hi,
 Is there a method to print the value of a tensor variable?

>>> -- 
>>
>> --- 
>> You received this message because you are subscribed to a topic in the 
>> Google Groups "theano-users" group.
>> To unsubscribe from this topic, visit 
>> https://groups.google.com/d/topic/theano-users/WVcBsiXG2w0/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to 
>> theano-users...@googlegroups.com .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"theano-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to theano-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[theano-users] Theano multiplication of different shape tensors

2017-01-28 Thread Antonis
Hi all, 

I would like to multiply a tensor4 of shape (a,1,c,d) with another tensor4 
with shape (a,b,c,d) with b!=1.
How can I do that in a theano function?
If I use a standard multiplication I get 'Input dimension mis-match'.

Thank you!
Antonis

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"theano-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to theano-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[theano-users] Problem with installation of gpuarray and with try_blas in Mac OS 10.12 Sierra

2017-01-28 Thread Orlando Bisacchi Coelho
I am installing Theano in a Mac running Sierra. My python installation 
comes from the last Anaconda release. Theano runs fine in the CPU but not 
in the GPU. 

During installation of gpuarray I came across some errors but using the 
workaround  python setup.py build_ext -I /usr/local/include -L /usr/local/
lib  sorted it out. 

When I try to run Theano in the GPU I get an OsX generated window that says:

try_blas_n_NNN cannot be opened because of a problem. [NNN is a 
alphanumeric code; every Theano run generates an error message with a 
different code.] 
Check with the developer to make sure try_blas_n_NNN works wit this version 
of MacOS. [Etc]

I did not install BLAS by myself. So I understand that the version of BLAS 
in use is the one provided by Apple's Accelerate framework. And that, on 
the other hand, python uses Intel's MLK library. But I can't figure out 
where exactly try_blas comes from. 

I've run that exhaustive Theano test. It generated the following errors. 
The path error is trivial to solve of course. Theano is not happy about 
gpuarray and I wonder if the problem is BLAS-related. But I have no clue on 
how to solve it. Can anyone give me a hint? Many thanks in advance.

Orlando

ERROR (theano.sandbox.cuda): nvcc compiler not found on $PATH. Check your 
nvcc installation and try again.


ERROR (theano.sandbox.cuda): nvcc compiler not found on $PATH. Check your 
nvcc installation and try again.

[repeated several times]


ERROR (theano.gof.opt): EquilibriumOptimizer max'ed out by 
'local_upcast_elemwise_constant_inputs'. You can safely raise the current 
threshold of 5.00 with the theano flag 'optdb.max_use_ratio'.


ERROR (theano.gof.opt): EquilibriumOptimizer max'ed out by 
'local_upcast_elemwise_constant_inputs'. You can safely raise the current 
threshold of 5.00 with the theano flag 'optdb.max_use_ratio'.

[repeated several times]


ERROR: Failure: RuntimeError (('Wrong major API version for gpuarray:', 1, 
'Make sure Theano and libgpuarray/pygpu are in sync.'))


RuntimeError: ('Wrong major API version for gpuarray:', 1, 'Make sure 
Theano and libgpuarray/pygpu are in sync.')

[repeated several times]


ERROR: Failure: RuntimeError (('Wrong major API version for gpuarray:', 1, 
'Make sure Theano and libgpuarray/pygpu are in sync.'))

[repeated several times]


RuntimeError: ('Wrong major API version for gpuarray:', 1, 'Make sure 
Theano and libgpuarray/pygpu are in sync.')

[repeated several times]


ERROR: Only test when pygpu isn't


ERROR: Failure: RuntimeError (('Wrong major API version for gpuarray:', 1, 
'Make sure Theano and libgpuarray/pygpu are in sync.'))


ERROR: Verify that the random numbers generated by GPUA_mrg_uniform, 
serially,


RuntimeError: ('Wrong major API version for gpuarray:', 1, 'Make sure 
Theano and libgpuarray/pygpu are in sync.')


ERROR: theano.sandbox.tests.test_rng_mrg.test_overflow_gpu_new_backend


RuntimeError: ('Wrong major API version for gpuarray:', 1, 'Make sure 
Theano and libgpuarray/pygpu are in sync.')


--

Ran 3002 tests in 36433.657s


FAILED (SKIP=89, errors=16) 

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"theano-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to theano-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[theano-users] Looking for an experienced keras programmer that knows how to make custom activations, loss functions and layers

2017-01-28 Thread Mustg Oplay


Please email me or message me in the kerasteam slack (mustgoplay).


Thanks

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"theano-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to theano-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [theano-users] Re: How to get the value of theano tensor variable

2017-01-28 Thread Mustg Oplay
This may help:

https://github.com/Theano/Theano/issues/5465

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"theano-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to theano-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[theano-users] Seeing what node's gradient is being computed

2017-01-28 Thread Kris Cao
Hi all

I'm trying to debug my model, which is randomly nan'ing at some point. I've 
turned on NanGuardMode and turned off optimization, but all it says is that 
a node which is being created in a call to theano.gradient.grad is causing 
the nan. This suggests that the model is nan'ing at some point during the 
gradient computations, but I was wondering whether it was possible to see 
which node's gradient is currently being computed, so I know where to look 
when debugging?

Thanks
Kris

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"theano-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to theano-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [theano-users] Re: How to get the value of theano tensor variable

2017-01-28 Thread Jesse Livezey
Did it give an error? If you're debugging things, eval is the right
function to use. If you're outputting the value of these variables during
training, you can just add them to the list of outputs when you create the
theano function.

On Fri, Jan 27, 2017 at 8:49 PM chathu matharage 
wrote:

> I need to get the value of Elementwise{tanh,no_inplace}.0 variable which
> is the output of error of logistic regression layer in convolution neural
> network. I tried with eval(). But it didn't work. Is there a method to get
> the error value of this type of variable?
>
>
> On Saturday, January 28, 2017 at 6:27:24 AM UTC+5:30, Jesse Livezey wrote:
>
> You can use eval
>
> http://deeplearning.net/software/theano/library/gof/graph.html#theano.gof.graph.Variable.eval
>
> On Friday, January 27, 2017 at 4:39:56 PM UTC-8, chathu matharage wrote:
>
> Hi,
> Is there a method to print the value of a tensor variable?
>
> --
>
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "theano-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/theano-users/WVcBsiXG2w0/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> theano-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"theano-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to theano-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[theano-users] How to save the best model of lenet in convolution neural network?

2017-01-28 Thread chathu matharage
Hi,
I'm developing a CNN to classify the MNIST dataset. The CNN is trained by 
using the firefly algorithm. I need to save the all layer information of 
the network while it trains in pickle file. Also need to read the pickle 
file and put an input on the network. So is there a way to save and read 
the best model of lenet?

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"theano-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to theano-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[theano-users] How to save the best model in LeNet in convolution neural network?

2017-01-28 Thread chathu matharage
Hi,
I need to save the all layer information of the best model of lenet. So 
what is the way to save the model and update it while training the network?

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"theano-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to theano-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.