theano/compile/builders.py
def _recompute_rop_op(self):
        '''
        converts self._rop_op from user supplied form to type(self) instance

        '''
        local_inputs = self.local_inputs
        local_outputs = self.local_outputs
        out_len = len(local_outputs)
        rop_op = self._rop_op

        if isinstance(rop_op, OpFromGraph):
            if not self._rop_op_is_cached:
                self._rop_op_is_cached = True
                self._rop_op_stypes_l = [None] * out_len
            return

        eval_points = [inp_t() for inp_t in self.input_types]
        fn_rop = partial(
            theano.gradient.Rop,
            wrt=local_inputs,
            eval_points=eval_points)
        TYPE_ERR_MSG = ("R_op overrides should be (single or list of)"
                        "OpFromGraph | 'default' | None | 0 | callable, got %s")
        STYPE_ERR_MSG = ('Overriding Variable instance can only have type'
                         ' of DisconnectedType or NullType, got %s')
        if rop_op == 'default':
            rdefaults_l = fn_rop(f=local_outputs)
            all_rops_l, all_rops_ov_l = izip(
                *[OpFromGraph._filter_rop_var(rop, out) for rop,
                  out in izip(rdefaults_l, local_outputs)])
            all_rops_l = list(all_rops_l)
            all_rops_ov_l = list(all_rops_ov_l)
        elif isinstance(rop_op, Variable):
            if isinstance(rop_op.type, NullType):
                all_rops_l = [inp.zeros_like() for inp in local_inputs]
                all_rops_ov_l = [rop_op.type() for _ in range(out_len)]
            elif isinstance(rop_op.type, DisconnectedType):
                all_rops_l = [inp.zeros_like() for inp in local_inputs]
                all_rops_ov_l = [None] * out_len
            else:
                raise ValueError(STYPE_ERR_MSG % rop_op.type)
        elif isinstance(rop_op, list):
            roverrides_l = rop_op
            if len(roverrides_l) != out_len:
                raise ValueError(
                    'Need to override %d Rop, got %d' % (
                        out_len, len(roverrides_l)), roverrides_l)
            # get outputs that does not have Rop override
            odefaults_l = [
                lo for lo, rov in izip(local_outputs, roverrides_l)
                if rov == 'default']
            rdefaults_l = fn_rop(f=odefaults_l)
            rdefaults = iter(rdefaults_l if odefaults_l else [])
            # combine overriding Rops
            all_rops_l = []
            all_rops_ov_l = []
            for out, fn_rov in izip(local_outputs, roverrides_l):
                if fn_rov == 'default':
                    rnext, rnext_ov = OpFromGraph._filter_rop_var(
                        next(rdefaults), out)
                    all_rops_l.append(rnext)
                    all_rops_ov_l.append(rnext_ov)
                elif isinstance(fn_rov, Variable):
                    if isinstance(fn_rov.type, NullType):
                        all_rops_l.append(out.zeros_like())
                        all_rops_ov_l.append(fn_rov.type())
                    if isinstance(fn_rov.type, DisconnectedType):
                        all_rops_l.append(out.zeros_like())
                        all_rops_ov_l.append(None)
                    else:
                        raise ValueError(STYPE_ERR_MSG % fn_rov.type)
                else:
                    if not callable(fn_rov):
                        raise TypeError(TYPE_ERR_MSG % fn_rov)
                    rov, rov_ov = OpFromGraph._filter_rop_var(
                        fn_rov(local_inputs, eval_points), out)
                    all_rops_l.append(rov)
                    all_rops_ov_l.append(rov_ov)
        else:
            if not callable(rop_op):
                raise TypeError(TYPE_ERR_MSG % rop_op)
            roverrides_l = rop_op(local_inputs, eval_points)
            if not isinstance(roverrides_l, list):
                raise TypeError(
                    'Rop overriding function should return a list, '
                    'got "%s"' % type(roverrides_l))
            all_rops_l, all_rops_ov_l = izip(
                *[OpFromGraph._filter_rop_var(
                    rop, out) for rop, out in izip(roverrides_l, local_outputs)])
            if len(all_rops_l) != out_len:
                raise ValueError(
                    'Rop overriding function %s should return list of '
                    '%d outputs, got %d' % (
                        self._rop_op, out_len,
                        len(all_rops_l)), rop_op)
            all_rops_l = list(all_rops_l)
            all_rops_ov_l = list(all_rops_ov_l)
        self._rop_op = type(self)(
            inputs=local_inputs + eval_points,
            outputs=all_rops_l,
            inline=self.is_inline,
            name=(None if self.name is None else self.name + '_rop'),
            on_unused_input='ignore')
        self._rop_op_stypes_l = all_rops_ov_l
        self._rop_op_is_cached = True

        converts self._rop_op from user supplied form to type(self) instance

        
converts self._rop_op from user supplied form to type(self) instance
converts self . _rop_op from user supplied form to type ( self ) instance
def _recompute_rop_op(self):
        local_inputs = self.local_inputs
        local_outputs = self.local_outputs
        out_len = len(local_outputs)
        rop_op = self._rop_op
        if isinstance(rop_op, OpFromGraph):
            if not self._rop_op_is_cached:
                self._rop_op_is_cached = True
                self._rop_op_stypes_l = [None] * out_len
            return
        eval_points = [inp_t() for inp_t in self.input_types]
        fn_rop = partial(
            theano.gradient.Rop,
            wrt=local_inputs,
            eval_points=eval_points)
        TYPE_ERR_MSG = ("R_op overrides should be (single or list of)"
                        "OpFromGraph | 'default' | None | 0 | callable, got %s")
        STYPE_ERR_MSG = ('Overriding Variable instance can only have type'
                         ' of DisconnectedType or NullType, got %s')
        if rop_op == 'default':
            rdefaults_l = fn_rop(f=local_outputs)
            all_rops_l, all_rops_ov_l = izip(
                *[OpFromGraph._filter_rop_var(rop, out) for rop,
                  out in izip(rdefaults_l, local_outputs)])
            all_rops_l = list(all_rops_l)
            all_rops_ov_l = list(all_rops_ov_l)
        elif isinstance(rop_op, Variable):
            if isinstance(rop_op.type, NullType):
                all_rops_l = [inp.zeros_like() for inp in local_inputs]
                all_rops_ov_l = [rop_op.type() for _ in range(out_len)]
            elif isinstance(rop_op.type, DisconnectedType):
                all_rops_l = [inp.zeros_like() for inp in local_inputs]
                all_rops_ov_l = [None] * out_len
            else:
                raise ValueError(STYPE_ERR_MSG % rop_op.type)
        elif isinstance(rop_op, list):
            roverrides_l = rop_op
            if len(roverrides_l) != out_len:
                raise ValueError(
                    'Need to override %d Rop, got %d' % (
                        out_len, len(roverrides_l)), roverrides_l)
            odefaults_l = [
                lo for lo, rov in izip(local_outputs, roverrides_l)
                if rov == 'default']
            rdefaults_l = fn_rop(f=odefaults_l)
            rdefaults = iter(rdefaults_l if odefaults_l else [])
            all_rops_l = []
            all_rops_ov_l = []
            for out, fn_rov in izip(local_outputs, roverrides_l):
                if fn_rov == 'default':
                    rnext, rnext_ov = OpFromGraph._filter_rop_var(
                        next(rdefaults), out)
                    all_rops_l.append(rnext)
                    all_rops_ov_l.append(rnext_ov)
                elif isinstance(fn_rov, Variable):
                    if isinstance(fn_rov.type, NullType):
                        all_rops_l.append(out.zeros_like())
                        all_rops_ov_l.append(fn_rov.type())
                    if isinstance(fn_rov.type, DisconnectedType):
                        all_rops_l.append(out.zeros_like())
                        all_rops_ov_l.append(None)
                    else:
                        raise ValueError(STYPE_ERR_MSG % fn_rov.type)
                else:
                    if not callable(fn_rov):
                        raise TypeError(TYPE_ERR_MSG % fn_rov)
                    rov, rov_ov = OpFromGraph._filter_rop_var(
                        fn_rov(local_inputs, eval_points), out)
                    all_rops_l.append(rov)
                    all_rops_ov_l.append(rov_ov)
        else:
            if not callable(rop_op):
                raise TypeError(TYPE_ERR_MSG % rop_op)
            roverrides_l = rop_op(local_inputs, eval_points)
            if not isinstance(roverrides_l, list):
                raise TypeError(
                    'Rop overriding function should return a list, '
                    'got "%s"' % type(roverrides_l))
            all_rops_l, all_rops_ov_l = izip(
                *[OpFromGraph._filter_rop_var(
                    rop, out) for rop, out in izip(roverrides_l, local_outputs)])
            if len(all_rops_l) != out_len:
                raise ValueError(
                    'Rop overriding function %s should return list of '
                    '%d outputs, got %d' % (
                        self._rop_op, out_len,
                        len(all_rops_l)), rop_op)
            all_rops_l = list(all_rops_l)
            all_rops_ov_l = list(all_rops_ov_l)
        self._rop_op = type(self)(
            inputs=local_inputs + eval_points,
            outputs=all_rops_l,
            inline=self.is_inline,
            name=(None if self.name is None else self.name + '_rop'),
            on_unused_input='ignore')
        self._rop_op_stypes_l = all_rops_ov_l
        self._rop_op_is_cached = True
def _recompute_rop_op ( self ) : local_inputs = self . local_inputs local_outputs = self . local_outputs out_len = len ( local_outputs ) rop_op = self . _rop_op if isinstance ( rop_op , OpFromGraph ) : if not self . _rop_op_is_cached : self . _rop_op_is_cached = True self . _rop_op_stypes_l = [ None ] * out_len return eval_points = [ inp_t ( ) for inp_t in self . input_types ] fn_rop = partial ( theano . gradient . Rop , wrt = local_inputs , eval_points = eval_points ) TYPE_ERR_MSG = ( "R_op overrides should be (single or list of)" "OpFromGraph | 'default' | None | 0 | callable, got %s" ) STYPE_ERR_MSG = ( 'Overriding Variable instance can only have type' ' of DisconnectedType or NullType, got %s' ) if rop_op == 'default' : rdefaults_l = fn_rop ( f = local_outputs ) all_rops_l , all_rops_ov_l = izip ( * [ OpFromGraph . _filter_rop_var ( rop , out ) for rop , out in izip ( rdefaults_l , local_outputs ) ] ) all_rops_l = list ( all_rops_l ) all_rops_ov_l = list ( all_rops_ov_l ) elif isinstance ( rop_op , Variable ) : if isinstance ( rop_op . type , NullType ) : all_rops_l = [ inp . zeros_like ( ) for inp in local_inputs ] all_rops_ov_l = [ rop_op . type ( ) for _ in range ( out_len ) ] elif isinstance ( rop_op . type , DisconnectedType ) : all_rops_l = [ inp . zeros_like ( ) for inp in local_inputs ] all_rops_ov_l = [ None ] * out_len else : raise ValueError ( STYPE_ERR_MSG % rop_op . type ) elif isinstance ( rop_op , list ) : roverrides_l = rop_op if len ( roverrides_l ) != out_len : raise ValueError ( 'Need to override %d Rop, got %d' % ( out_len , len ( roverrides_l ) ) , roverrides_l ) odefaults_l = [ lo for lo , rov in izip ( local_outputs , roverrides_l ) if rov == 'default' ] rdefaults_l = fn_rop ( f = odefaults_l ) rdefaults = iter ( rdefaults_l if odefaults_l else [ ] ) all_rops_l = [ ] all_rops_ov_l = [ ] for out , fn_rov in izip ( local_outputs , roverrides_l ) : if fn_rov == 'default' : rnext , rnext_ov = OpFromGraph . _filter_rop_var ( next ( rdefaults ) , out ) all_rops_l . append ( rnext ) all_rops_ov_l . append ( rnext_ov ) elif isinstance ( fn_rov , Variable ) : if isinstance ( fn_rov . type , NullType ) : all_rops_l . append ( out . zeros_like ( ) ) all_rops_ov_l . append ( fn_rov . type ( ) ) if isinstance ( fn_rov . type , DisconnectedType ) : all_rops_l . append ( out . zeros_like ( ) ) all_rops_ov_l . append ( None ) else : raise ValueError ( STYPE_ERR_MSG % fn_rov . type ) else : if not callable ( fn_rov ) : raise TypeError ( TYPE_ERR_MSG % fn_rov ) rov , rov_ov = OpFromGraph . _filter_rop_var ( fn_rov ( local_inputs , eval_points ) , out ) all_rops_l . append ( rov ) all_rops_ov_l . append ( rov_ov ) else : if not callable ( rop_op ) : raise TypeError ( TYPE_ERR_MSG % rop_op ) roverrides_l = rop_op ( local_inputs , eval_points ) if not isinstance ( roverrides_l , list ) : raise TypeError ( 'Rop overriding function should return a list, ' 'got "%s"' % type ( roverrides_l ) ) all_rops_l , all_rops_ov_l = izip ( * [ OpFromGraph . _filter_rop_var ( rop , out ) for rop , out in izip ( roverrides_l , local_outputs ) ] ) if len ( all_rops_l ) != out_len : raise ValueError ( 'Rop overriding function %s should return list of ' '%d outputs, got %d' % ( self . _rop_op , out_len , len ( all_rops_l ) ) , rop_op ) all_rops_l = list ( all_rops_l ) all_rops_ov_l = list ( all_rops_ov_l ) self . _rop_op = type ( self ) ( inputs = local_inputs + eval_points , outputs = all_rops_l , inline = self . is_inline , name = ( None if self . name is None else self . name + '_rop' ) , on_unused_input = 'ignore' ) self . _rop_op_stypes_l = all_rops_ov_l self . _rop_op_is_cached = True
converts self._rop_op from user supplied form to type(self) instance
converts self . _rop_op from user supplied form to type ( self ) instance
'''
        converts self._rop_op from user supplied form to type(self) instance

        ''' # get outputs that does not have Rop override # combine overriding Rops
self