(self, data_instances, model_weights, n_iter_, batch_index, offset, loss_norm=None)
Compute hetero poisson loss:
            loss = sum(exp(mu_g)*exp(mu_h) - y(wx_g + wx_h) + log(exposure))

        Parameters:
        ___________
        data_instances: Table, input data

        model_weights: model weight object, stores intercept_ and coef_

        n_iter_: int, current number of iter.

        batch_index: int, use to obtain current encrypted_calculator index

        offset: log(exposure)

        loss_norm: penalty term, default to None
Compute hetero poisson loss:
            loss = sum(exp(mu_g)*exp(mu_h) - y(wx_g + wx_h) + log(exposure))
Compute hetero poisson loss : loss = sum ( exp ( mu_g ) * exp ( mu_h ) - y ( wx_g + wx_h ) + log ( exposure ))
def compute_loss(self, data_instances, model_weights, n_iter_, batch_index, offset, loss_norm=None):
        '''
        Compute hetero poisson loss:
            loss = sum(exp(mu_g)*exp(mu_h) - y(wx_g + wx_h) + log(exposure))

        Parameters:
        ___________
        data_instances: Table, input data

        model_weights: model weight object, stores intercept_ and coef_

        n_iter_: int, current number of iter.

        batch_index: int, use to obtain current encrypted_calculator index

        offset: log(exposure)

        loss_norm: penalty term, default to None

        '''
        current_suffix = (n_iter_, batch_index)
        n = data_instances.count()
        guest_wx_y = data_instances.join(offset,
                                         lambda v, m: (
                                             vec_dot(v.features, model_weights.coef_) + model_weights.intercept_ + m,
                                             v.label))
        loss_list = []
        host_wxs = 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:
            raise ValueError("More than one host exists. Poisson regression does not support multi-host.")

        host_mu = self.host_forwards[0]
        host_wx = host_wxs[0]
        loss_wx = guest_wx_y.join(host_wx, lambda g, h: g[1] * (g[0] + h)).reduce(reduce_add)
        loss_mu = self.forwards.join(host_mu, lambda g, h: g * h).reduce(reduce_add)
        loss = (loss_mu - loss_wx) / n
        if loss_norm is not None:
            loss = loss + loss_norm + host_loss_regular[0]
        loss_list.append(loss)
        self.sync_loss_info(loss_list, suffix=current_suffix)
def compute_loss ( self , data_instances , model_weights , n_iter_ , batch_index , offset , loss_norm = None ) : current_suffix = ( n_iter_ , batch_index ) n = data_instances . count ( ) guest_wx_y = data_instances . join ( offset , lambda v , m : ( vec_dot ( v . features , model_weights . coef_ ) + model_weights . intercept_ + m , v . label ) ) loss_list = [ ] host_wxs = 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 : raise ValueError ( "More than one host exists. Poisson regression does not support multi-host." ) host_mu = self . host_forwards [ 0 ] host_wx = host_wxs [ 0 ] loss_wx = guest_wx_y . join ( host_wx , lambda g , h : g [ 1 ] * ( g [ 0 ] + h ) ) . reduce ( reduce_add ) loss_mu = self . forwards . join ( host_mu , lambda g , h : g * h ) . reduce ( reduce_add ) loss = ( loss_mu - loss_wx ) / n if loss_norm is not None : loss = loss + loss_norm + host_loss_regular [ 0 ] loss_list . append ( loss ) self . sync_loss_info ( loss_list , suffix = current_suffix )