Github user cooper-sloan commented on a diff in the pull request:

    https://github.com/apache/incubator-madlib/pull/149#discussion_r127080429
  
    --- Diff: src/modules/convex/mlp_igd.cpp ---
    @@ -0,0 +1,260 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + *   http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing,
    + * software distributed under the License is distributed on an
    + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    + * KIND, either express or implied.  See the License for the
    + * specific language governing permissions and limitations
    + * under the License.
    + *
    + * @file mlp_igd.cpp
    + *
    + * @brief Low-rank Matrix Factorization functions
    + *
    + *//* 
----------------------------------------------------------------------- */
    +#include <boost/lexical_cast.hpp>
    +
    +#include <dbconnector/dbconnector.hpp>
    +#include <modules/shared/HandleTraits.hpp>
    +
    +#include "mlp_igd.hpp"
    +
    +#include "task/mlp.hpp"
    +#include "algo/igd.hpp"
    +#include "algo/loss.hpp"
    +
    +#include "type/tuple.hpp"
    +#include "type/model.hpp"
    +#include "type/state.hpp"
    +
    +namespace madlib {
    +
    +namespace modules {
    +
    +namespace convex {
    +
    +// These 2 classes contain public static methods that can be called
    +typedef IGD<MLPIGDState<MutableArrayHandle<double> >, 
MLPIGDState<ArrayHandle<double> >,
    +        MLP<MLPModel<MutableArrayHandle<double> >, MLPTuple > > 
MLPIGDAlgorithm;
    +
    +typedef Loss<MLPIGDState<MutableArrayHandle<double> >, 
MLPIGDState<ArrayHandle<double> >,
    +        MLP<MLPModel<MutableArrayHandle<double> >, MLPTuple > > 
MLPLossAlgorithm;
    +
    +typedef MLP<MLPModel<MutableArrayHandle<double> >,MLPTuple> MLPTask;
    +
    +/**
    + * @brief Perform the multi-layer perceptron transition step
    + *
    + * Called for each tuple.
    + */
    +AnyType
    +mlp_igd_transition::run(AnyType &args) {
    +    // For the first tuple: args[0] is nothing more than a marker that
    +    // indicates that we should do some initial operations.
    +    // For other tuples: args[0] holds the computation state until last 
tuple
    +    MLPIGDState<MutableArrayHandle<double> > state = args[0];
    +
    +    // initilize the state if first tuple
    +    if (state.algo.numRows == 0) {
    +        if (!args[3].isNull()) {
    +            MLPIGDState<ArrayHandle<double> > previousState = args[3];
    +
    +            state.allocate(*this, previousState.task.numberOfStages,
    +                           previousState.task.numbersOfUnits);
    +            state = previousState;
    +        } else {
    +            // configuration parameters
    +            ArrayHandle<double> numbersOfUnits = 
args[4].getAs<ArrayHandle<double> >();
    +            if (numbersOfUnits.size() <= 1) {
    +                throw std::runtime_error("Invalid parameter: 
numbers_of_units "
    +                        "has too few entries");
    +            } else if (numbersOfUnits.size() >=
    +                    std::numeric_limits<uint16_t>::max()) {
    +                throw std::runtime_error("Invalid parameter: 
numbers_of_units "
    +                        "has too many entries");
    +            }
    +            size_t k;
    +            for (k = 0; k < numbersOfUnits.size(); k ++) {
    +                if (numbersOfUnits[k] == 0) {
    +                throw std::runtime_error("Invalid parameter: 
numbers_of_units "
    +                        "has zero entry");
    +                }
    +            }
    +
    +            double stepsize = args[5].getAs<double>();
    +            if (stepsize <= 0.) {
    +                throw std::runtime_error("Invalid parameter: stepsize <= 
0.0");
    --- End diff --
    
    Good catch. I think I will remove this validation as it is done in python 
layer.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to