(self, data_instances, n_iter_, batch_index, loss_norm=None)
Compute hetero linr loss:
            loss = (1/N)*\sum(wx-y)^2 where y is label, w is model weight and x is features
        log(wx - y)^2 = (wx_h)^2 + (wx_g - y)^2 + 2*(wx_h + wx_g - y)
Compute hetero linr loss:
            loss = (1/N)*\sum(wx-y)^2 where y is label, w is model weight and x is features
        log(wx - y)^2 = (wx_h)^2 + (wx_g - y)^2 + 2*(wx_h + wx_g - y)
Compute hetero linr loss : loss = ( 1 / N ) * \ sum ( wx - y ) ^2 where y is label w is model weight and x is features log ( wx - y ) ^2 = ( wx_h ) ^2 + ( wx_g - y ) ^2 + 2 * ( wx_h + wx_g - y )
def compute_loss(self, data_instances, n_iter_, batch_index, loss_norm=None):
        '''
        Compute hetero linr loss:
            loss = (1/N)*\sum(wx-y)^2 where y is label, w is model weight and x is features
        log(wx - y)^2 = (wx_h)^2 + (wx_g - y)^2 + 2*(wx_h + wx_g - y)
        '''
        current_suffix = (n_iter_, batch_index)
        n = data_instances.count()
        loss_list = []
        host_wx_squares = self.get_host_loss_intermediate(current_suffix)

        if loss_norm is not None:
            host_loss_regular = self.get_host_loss_regular(suffix=current_suffix)
        else:
            host_loss_regular = []
        if len(self.host_forwards) > 1:
            LOGGER.info("More than one host exist, loss is not available")
        else:
            host_forward = self.host_forwards[0]
            host_wx_square = host_wx_squares[0]

            wxy_square = self.half_d.mapValues(lambda x: np.square(x)).reduce(reduce_add)

            loss_gh = self.half_d.join(host_forward, lambda g, h: g * h).reduce(reduce_add)
            loss = (wxy_square + host_wx_square + 2 * loss_gh) / (2 * n)
            if loss_norm is not None:
                loss = loss + loss_norm + host_loss_regular[0]
            loss_list.append(loss)
        # LOGGER.debug("In compute_loss, loss list are: {}".format(loss_list))
        self.sync_loss_info(loss_list, suffix=current_suffix)
def compute_loss ( self , data_instances , n_iter_ , batch_index , loss_norm = None ) : current_suffix = ( n_iter_ , batch_index ) n = data_instances . count ( ) loss_list = [ ] host_wx_squares = self . get_host_loss_intermediate ( current_suffix ) if loss_norm is not None : host_loss_regular = self . get_host_loss_regular ( suffix = current_suffix ) else : host_loss_regular = [ ] if len ( self . host_forwards ) > 1 : LOGGER . info ( "More than one host exist, loss is not available" ) else : host_forward = self . host_forwards [ 0 ] host_wx_square = host_wx_squares [ 0 ] wxy_square = self . half_d . mapValues ( lambda x : np . square ( x ) ) . reduce ( reduce_add ) loss_gh = self . half_d . join ( host_forward , lambda g , h : g * h ) . reduce ( reduce_add ) loss = ( wxy_square + host_wx_square + 2 * loss_gh ) / ( 2 * n ) if loss_norm is not None : loss = loss + loss_norm + host_loss_regular [ 0 ] loss_list . append ( loss ) # LOGGER.debug("In compute_loss, loss list are: {}".format(loss_list)) self . sync_loss_info ( loss_list , suffix = current_suffix )