func (t *bwmfTask) updateDShard(ctx context.Context) {
	if t.dims.N == -1 {
		t.dims.N = 0
		for _, m := range t.peerShards {
			t.dims.N += len(m.Row)
		}
		wh := make([][]float32, t.dims.N)
		for i, _ := range wh {
			wh[i] = make([]float32, t.dims.m)
		}
		t.dLoss = &KLDivLoss{
			V:  t.rowShard,
			WH: wh,
			m:  t.dims.N,
			n:  t.dims.m,
			k:  t.dims.k,
		}
	}

	t.dLoss.W = NewBlocksParameter(&t.peerShards)
	param := NewSingleBlockParameter(t.dShard)

	loss, optErr := t.optimizer.Minimize(t.dLoss, t.stopCriteria, param)
	if optErr != nil {
		t.logger.Panicf("Failed minimizing over dShard: %s", optErr)
		// handle re-run
		// XXX(baigang) just kill the framework and wait for restarting?
	}
	t.logger.Printf("Updated dShard, loss is %f", loss)

	t.updateDone <- &event{ctx: ctx}
}
// These two function carry out actual optimization.
These two function carry out actual optimization.
// These two function carry out actual optimization .
func (t *bwmfTask) updateDShard(ctx context.Context) {
	if t.dims.N == -1 {
		t.dims.N = 0
		for _, m := range t.peerShards {
			t.dims.N += len(m.Row)
		}
		wh := make([][]float32, t.dims.N)
		for i, _ := range wh {
			wh[i] = make([]float32, t.dims.m)
		}
		t.dLoss = &KLDivLoss{
			V:  t.rowShard,
			WH: wh,
			m:  t.dims.N,
			n:  t.dims.m,
			k:  t.dims.k,
		}
	}
	t.dLoss.W = NewBlocksParameter(&t.peerShards)
	param := NewSingleBlockParameter(t.dShard)
	loss, optErr := t.optimizer.Minimize(t.dLoss, t.stopCriteria, param)
	if optErr != nil {
		t.logger.Panicf("Failed minimizing over dShard: %s", optErr)
	}
	t.logger.Printf("Updated dShard, loss is %f", loss)
	t.updateDone <- &event{ctx: ctx}
}
func ( t * bwmfTask ) updateDShard ( ctx context . Context ) { if t . dims . N == - 1 { t . dims . N = 0 for _ , m := range t . peerShards { t . dims . N += len ( m . Row ) } wh := make ( [ ] [ ] float32 , t . dims . N ) for i , _ := range wh { wh [ i ] = make ( [ ] float32 , t . dims . m ) } t . dLoss = & KLDivLoss { V : t . rowShard , WH : wh , m : t . dims . N , n : t . dims . m , k : t . dims . k , } } t . dLoss . W = NewBlocksParameter ( & t . peerShards ) param := NewSingleBlockParameter ( t . dShard ) loss , optErr := t . optimizer . Minimize ( t . dLoss , t . stopCriteria , param ) if optErr != nil { t . logger . Panicf ( " " , optErr ) } t . logger . Printf ( " " , loss ) t . updateDone <- & event { ctx : ctx } }
These two function carry out actual optimization.
These two function carry out actual optimization .
// handle re-run // XXX(baigang) just kill the framework and wait for restarting?