def get_fixed_var_descr(self, model, data): data_specs = self.get_data_specs(model) data_specs[0].validate(data) rval = FixedVarDescr() rval.fixed_vars = {'sup_aux_var': sup_counter} rval.data_specs = data_specs # data has to be flattened into a tuple before being passed # to `function`. mapping = DataSpecsMapping(data_specs) flat_data = mapping.flatten(data, return_tuple=True) theano_func = function(flat_data, updates=[(sup_counter, sup_counter + 1)]) # the on_load_batch function will take numerical data formatted # as rval.data_specs, so we have to flatten it inside the # returned function too. # Using default argument binds the variables used in the lambda # function to the value they have when the lambda is defined. on_load = (lambda batch, mapping=mapping, theano_func=theano_func: theano_func(*mapping.flatten(batch, return_tuple=True))) rval.on_load_batch = [on_load] return rval
def get_fixed_var_descr(self, model, data): data_specs = self.get_data_specs(model) data_specs[0].validate(data) rval = FixedVarDescr() rval.fixed_vars = {'sup_aux_var': sup_counter} rval.data_specs = data_specs # data has to be flattened into a tuple before being passed # to `function`. mapping = DataSpecsMapping(data_specs) flat_data = mapping.flatten(data, return_tuple=True) theano_func = function(flat_data, updates=[(sup_counter, sup_counter + 1)]) # the on_load_batch function will take numerical data formatted # as rval.data_specs, so we have to flatten it inside the # returned function too. # Using default argument binds the variables used in the lambda # function to the value they have when the lambda is defined. on_load = (lambda batch, mapping=mapping, theano_func=theano_func: theano_func(*mapping.flatten(batch, return_tuple=True))) rval.on_load_batch = [on_load] return rval
def get_fixed_var_descr(self, model, data, **kwargs): data_specs = self.get_data_specs(model) data_specs[0].validate(data) rval = FixedVarDescr() rval.fixed_vars = {'unsup_aux_var': unsup_counter} rval.data_specs = data_specs # The input to function should be a flat, non-redundent tuple mapping = DataSpecsMapping(data_specs) data_tuple = mapping.flatten(data, return_tuple=True) theano_func = function(data_tuple, updates=[(unsup_counter, unsup_counter + 1)]) # the on_load_batch function will take numerical data formatted # as rval.data_specs, so we have to flatten it inside the # returned function too. # Using default argument binds the variables used in the lambda # function to the value they have when the lambda is defined. on_load = (lambda batch, mapping=mapping, theano_func=theano_func: theano_func(*mapping.flatten(batch, return_tuple=True))) rval.on_load_batch = [on_load] return rval
def get_fixed_var_descr(self, model, data, **kwargs): data_specs = self.get_data_specs(model) data_specs[0].validate(data) rval = FixedVarDescr() rval.fixed_vars = {'unsup_aux_var': unsup_counter} rval.data_specs = data_specs # The input to function should be a flat, non-redundent tuple mapping = DataSpecsMapping(data_specs) data_tuple = mapping.flatten(data, return_tuple=True) theano_func = function(data_tuple, updates=[(unsup_counter, unsup_counter + 1) ]) # the on_load_batch function will take numerical data formatted # as rval.data_specs, so we have to flatten it inside the # returned function too. # Using default argument binds the variables used in the lambda # function to the value they have when the lambda is defined. on_load = (lambda batch, mapping=mapping, theano_func=theano_func: theano_func(*mapping.flatten(batch, return_tuple=True))) rval.on_load_batch = [on_load] return rval