Github user njayaram2 commented on a diff in the pull request:

    https://github.com/apache/madlib/pull/251#discussion_r178204067
  
    --- Diff: src/modules/convex/mlp_igd.cpp ---
    @@ -98,23 +98,28 @@ mlp_igd_transition::run(AnyType &args) {
     
                 double is_classification_double = (double) is_classification;
                 double activation_double = (double) activation;
    -            MappedColumnVector coeff = 
args[10].getAs<MappedColumnVector>();
    -            
state.task.model.rebind(&is_classification_double,&activation_double,
    -                                    &coeff.data()[0], numberOfStages,
    -                                    &numbersOfUnits[0]);
    -
    -            // state.task.model.is_classification =
    -            //     static_cast<double>(is_classification);
    -            // state.task.model.activation = 
static_cast<double>(activation);
    -            // MappedColumnVector initial_coeff = 
args[10].getAs<MappedColumnVector>();
    -            // // copy initial_coeff into the model
    -            // Index fan_in, fan_out, layer_start = 0;
    -            // for (size_t k = 0; k < numberOfStages; ++k){
    -            //     fan_in = numbersOfUnits[k];
    -            //     fan_out = numbersOfUnits[k+1];
    -            //     state.task.model.u[k] << 
initial_coeff.segment(layer_start, (fan_in+1)*fan_out);
    -            //     layer_start = (fan_in + 1) * fan_out;
    -            // }
    +            if (!args[10].isNull()){
    +                // initial coefficients are provided
    +                MappedColumnVector warm_start_coeff = 
args[10].getAs<MappedColumnVector>();
    +
    +                // copy warm start into the task model
    +                // state.reset() ensures algo.incrModel is copied from 
task.model
    +                Index layer_start = 0;
    +                for (size_t k = 0; k < numberOfStages; ++k){
    +                    for (size_t j=0; j < state.task.model.u[k].cols(); 
++j){
    +                        for (size_t i=0; i < state.task.model.u[k].rows(); 
++i){
    +                            state.task.model.u[k](i, j) = warm_start_coeff(
    +                                layer_start + j * 
state.task.model.u[k].rows() + i);
    +                        }
    +                    }
    +                    layer_start = state.task.model.u[k].rows() * 
state.task.model.u[k].cols();
    +                }
    +            } else {
    +                // initialize the model with appropriate coefficients
    +                state.task.model.initialize(
    --- End diff --
    
    This is more of a doubt than a comment I guess. Should this be 
`state.algo.incrModel` instead?
    The reason I thought so was that `MLPIGDAlgorithm::transition(state, 
tuple);` uses the model in algo instead of the one task.


---

Reply via email to