rfho/hyper_gradients.py
def hyper_gradients(self, val_feed_dict_supplier=None, hyper_batch_step=None):
        """
        Method that computes the hyper-gradient.

        :param hyper_batch_step: support for stochastic sampling of validation points
        :param val_feed_dict_supplier: single  supplier or list of suppliers for the examples in the validation set

        :return: Dictionary: {hyper-parameter: hyper-gradient} or None in new_mode
        """
        if not isinstance(val_feed_dict_supplier, dict) and len(self.hyper_list) == 1:  # fine if there is only 1 hyper
            val_feed_dict_supplier = {self.hyper_list[0]: val_feed_dict_supplier}

        val_sup_lst = []
        if val_feed_dict_supplier is None:
            val_sup_lst = [lambda: None] * len(self.hyper_list)
        else:
            for hyp in self.hyper_list:  # find the right validation error for hyp!
                for k, v in self.hyper_dict.items():
                    all_hypers = [e[0] if isinstance(e, (list, tuple)) else e for e in v]
                    if hyp in all_hypers:
                        val_sup_lst.append(val_feed_dict_supplier[k])
                        break

        # NEW VARIABLE-BASED HYPER-GRADIENTS
        [assign_op.eval(feed_dict=cmo(vsl, hyper_batch_step)) for
         assign_op, vsl in zip(self._hyper_assign_ops, val_sup_lst)]

        return {hyp: self.hyper_gradients_dict[hyp].eval() for hyp in self.hyper_list}

        Method that computes the hyper-gradient.

        :param hyper_batch_step: support for stochastic sampling of validation points
        :param val_feed_dict_supplier: single  supplier or list of suppliers for the examples in the validation set

        :return: Dictionary: {hyper-parameter: hyper-gradient} or None in new_mode
        
Method that computes the hyper-gradient.
Method that computes the hyper - gradient .
def hyper_gradients(self, val_feed_dict_supplier=None, hyper_batch_step=None):
        if not isinstance(val_feed_dict_supplier, dict) and len(self.hyper_list) == 1:  
            val_feed_dict_supplier = {self.hyper_list[0]: val_feed_dict_supplier}
        val_sup_lst = []
        if val_feed_dict_supplier is None:
            val_sup_lst = [lambda: None] * len(self.hyper_list)
        else:
            for hyp in self.hyper_list:  
                for k, v in self.hyper_dict.items():
                    all_hypers = [e[0] if isinstance(e, (list, tuple)) else e for e in v]
                    if hyp in all_hypers:
                        val_sup_lst.append(val_feed_dict_supplier[k])
                        break
        [assign_op.eval(feed_dict=cmo(vsl, hyper_batch_step)) for
         assign_op, vsl in zip(self._hyper_assign_ops, val_sup_lst)]
        return {hyp: self.hyper_gradients_dict[hyp].eval() for hyp in self.hyper_list}
def hyper_gradients ( self , val_feed_dict_supplier = None , hyper_batch_step = None ) : if not isinstance ( val_feed_dict_supplier , dict ) and len ( self . hyper_list ) == 1 : val_feed_dict_supplier = { self . hyper_list [ 0 ] : val_feed_dict_supplier } val_sup_lst = [ ] if val_feed_dict_supplier is None : val_sup_lst = [ lambda : None ] * len ( self . hyper_list ) else : for hyp in self . hyper_list : for k , v in self . hyper_dict . items ( ) : all_hypers = [ e [ 0 ] if isinstance ( e , ( list , tuple ) ) else e for e in v ] if hyp in all_hypers : val_sup_lst . append ( val_feed_dict_supplier [ k ] ) break [ assign_op . eval ( feed_dict = cmo ( vsl , hyper_batch_step ) ) for assign_op , vsl in zip ( self . _hyper_assign_ops , val_sup_lst ) ] return { hyp : self . hyper_gradients_dict [ hyp ] . eval ( ) for hyp in self . hyper_list }
Method that computes the hyper-gradient.
Method that computes the hyper - gradient .
"""
        Method that computes the hyper-gradient.

        :param hyper_batch_step: support for stochastic sampling of validation points
        :param val_feed_dict_supplier: single  supplier or list of suppliers for the examples in the validation set

        :return: Dictionary: {hyper-parameter: hyper-gradient} or None in new_mode
        """ # fine if there is only 1 hyper # find the right validation error for hyp! # NEW VARIABLE-BASED HYPER-GRADIENTS
{hyper-parameter: hyper-gradient} or None in new_mode
{ hyper - parameter : hyper - gradient } or None in new_mode
self
val_feed_dict_supplier
single  supplier or list of suppliers for the examples in the validation set
single supplier or list of suppliers for the examples in the validation set
hyper_batch_step
support for stochastic sampling of validation points
support for stochastic sampling of validation points