Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ELM update #845

Closed
wants to merge 7 commits into from
Closed

ELM update #845

wants to merge 7 commits into from

Conversation

Siddharth8
Copy link

Please review it and let me know

@rcurtin
Copy link
Member

rcurtin commented Dec 25, 2016

Hi there, thanks for the contributions. Before I review this, please add tests and ensure that the code conforms to the mlpack style guidelines.

@mlpack-mailing-lists
Copy link

mlpack-mailing-lists commented Dec 26, 2016 via email


namespace mlpack {
namespace elm {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add comment at here, explain the purpose of this class and give some example. You can take softmax as example.


class ELM
{
private:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make your style conform to requirements of mlpack. Like naming rule, how many space should be used etc.
You can check the details at here.

examples :

In mlpack, class member should names as
"trainTime", "weight" "NPrime" and so on.

space before private and public should be one.
space before parameter should be two

double Test_Accuracy;

public:
void Set_Dim(uint16_t Nh, uint16_t D, uint16_t N);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

member name should be SetDim and so on

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Besides, please write test cases for your class.You can use softmax as example too.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an old initial commit. Please review the new code

class ELM
{
private:
uint16_t N_prime; //Number of Hidden Neurons
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason to pick uint16_t but not size_t?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No it's fine to use size_t !!

public:
Elm(const arma::mat& predictors,
const arma::mat& responses,
const size_t act=0,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where are the data member of act, Nh, N, D? Do you compile your codes before you commit it?
Please do not omit the error/warning messages of your compiler, they are important and helpful .

If possible, please change the parameter to longer, readable name, like
"hiddenNeurons, dataPoints, dimension".

I like the way you change x_train, y_train to predictors and responses, this make things more readable 👍


const size_t act = CLI::GetParam<size_t>("Activation_type");

elm.Nh = Nh;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not make your data member as global.

*/

#ifndef MLPACK_METHODS_Elm_HPP
#define MLPACK_METHODS_Elm_HPP
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please keep all of the characters as upper letter


switch(act)
{
case 0 :for(size_t i=0; i<H.n_rows; ++i)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than using 0,1,2,3, why not we make it as enum?It is easier to read

enum class Act
{
  sigmoid,
  sine,
  hardlim,
  triangularBias,
  radialBasis
};

switch(act)
{
  case sigmoid : //......
}

{
arma::mat weight = arma::randu<arma::mat>(Nh);
arma::mat bias = arma::randu<arma::mat>(Nh);
arma::mat beta = arma::randu<arma::mat>(Nh);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are the purpose of these temporary parameters doing(weight, bias, beta)?
If they are no special reasons to put them at here, please remove them.
If you do have some special reasons, please write it down, because this is unusual and
may make other maintainer confuse. Thanks

default : Log::Fatal << "Please select a suitable activation function to proceed:" << std::endl;
}

mat H_inv = pinv(H); // Moore-Penrose pseudo-inverse of matrix H
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make them as const if the value would not be changed. const is a simple yet powerful abstraction mechanism to help you write high quality codes.


mat predictions = H * beta; // predict the output of ELM
arma::mat Elm_output = arma::randu<arma::mat>(N);
Elm_output = predictions;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are the purposes of this temporary parameter?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not save the output to the csv after predict but let the user have the output results directly.
I suggest you change the api to

void ELM::Predict(const arma::mat& points, arma::mat& predictions);


void ELM::Train(const arma::mat& predictors,
const arma::mat& responses,
const size_t act)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this function do not alter the value of data member, please make this as const function

}

mat H_inv = pinv(H); // Moore-Penrose pseudo-inverse of matrix H
beta = H_inv * responses; //Calculate output weights
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where are this beta come from?

beta = H_inv * responses; //Calculate output weights
mat trainingOutput = H * beta; // Calculate training accuracy
vec temp = responses - trainingOutput;
double trainError = stddev(temp); //calculate training error
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are the purposes of this train function?It do not change any states of the class nor provide any output.

@rcurtin
Copy link
Member

rcurtin commented Mar 29, 2017

Closing for inactivity. If you'd like to keep working on this we can reopen it of course.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants