You should compile 1 theano function per network. You can put them in a
list and index that list to find the good funtion to call.

Fred

On Thu, Jul 28, 2016 at 11:42 AM Florin <[email protected]> wrote:

> I have a similar problem:
>
> out = lasagne.layers.get_output(nets[index], x)
> theano.function([index], out, givens= {x: inputs})
>
> I basically have a list of neural networks nets and want to dynamically
> select which to evaluate, depending on index. How could I do this?
>
> Cris
>
> On Tuesday, March 10, 2015 at 9:10:58 AM UTC-4, nouiz wrote:
>
>> Do all element of the list have the same size? If so, I would recommand
>> to make an ndarray with 1 extra dimensions instead of putting this in a
>> list. Then you can put this ndarray as a shared variable
>>
>> example:
>>
>> nd_list = numpy.ndarray(list)
>> shared_var = theano.shared(nd_list)
>>
>> then you can do:
>>
>> shared_var[index]
>>
>> And use that in a Theano function.
>>
>> Otherwise, you can use typed list:
>>
>> http://deeplearning.net/software/theano/library/typed_list.html
>>
>> Fred
>>
> On Tue, Mar 10, 2015 at 9:03 AM, Rob <[email protected]> wrote:
>>
> I have circumvented the problem. Rather than creating a list of tensor on
>>> which I apply a single theano function, I just created a list of theano
>>> functions (one for each tensor).
>>>
>>> If there are better solutions I would still love to here them.
>>>
>>>
>>> On Tuesday, 10 March 2015 12:46:05 UTC, Rob wrote:
>>>>
>>>> I want a theano function that, given a scalar input, will return a
>>>> tensor stored in a list at the index of that scalar. i.e
>>>>
>>>> theano.function([index],list[index],givens= {x: <some function of index
>>>> >})
>>>>
>>>> where the list contains different x-dependent tensors that I want to
>>>> evaluate depending on the index given.
>>>>
>>>> This generates error:
>>>>
>>>> TypeError: list indices must be integers, not TensorVariable
>>>>
>>>>
>>>> I'm very new to Theano so I'm probably thinking about this problem in
>>>> the wrong way. I would really appreciate any advice.
>>>>
>>>> Rob
>>>>
>>> --
>>>
>>> ---
>>> 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 [email protected].
>>>
>>
>>> 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 [email protected].
> 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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to