Python list don't know how to handle Theano variable. You can't miss them. Convert your list to a Theano tensor. Maybe theano.shared(your list) will work for your case.
Le sam. 27 mai 2017 17:50, Bavani Sankar <[email protected]> a écrit : > I have a python list I want to splice... I also have the theano tensor > scalar 'i': > >> i = T.lscalar() >> >> > How do I use this scalar to splice the list? > This code that used to work, no longer works: > >> training_x[i * self.mini_batch_size: (i + 1) * self.mini_batch_size] >> >> I get the error: "TypeError: slice indices must be integers or None or > have an __index__ method" > Can you please help me out? > > > On Thursday, July 28, 2016 at 9:49:21 PM UTC+5:30, nouiz wrote: > >> 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. > -- --- 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.
