Skip to content

Conversation

@akropp
Copy link
Contributor

@akropp akropp commented Nov 27, 2023

Adding two ANN layer types:

  • RepeatType -- Repeat input tensors along one dimension n times, similar to the arma::repelem function or tensorflow.repeat
  • ReplicateType -- Replicate the input in a block-like fasion across each dimension a specified number of times, similar to arma::repmat or tensorflow.tile

Copy link
Member

@rcurtin rcurtin left a comment

Choose a reason for hiding this comment

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

Thanks, these are important and nice layers to add. Sorry it took me so long to get to this review. I only did a quick pass so far---most of my specific comments are style-related, or comment-related.

The two classes are very similar. I wonder if it makes more sense to the user if we just create one layer Repeat, and whether it interleaves (like repelem()) or block copies (like repmat()) is a boolean parameter. What do you think?

@akropp
Copy link
Contributor Author

akropp commented Dec 12, 2023

Thanks, these are important and nice layers to add. Sorry it took me so long to get to this review. I only did a quick pass so far---most of my specific comments are style-related, or comment-related.

The two classes are very similar. I wonder if it makes more sense to the user if we just create one layer Repeat, and whether it interleaves (like repelem()) or block copies (like repmat()) is a boolean parameter. What do you think?

I definitely had that thought. It seemed that the two concepts are kept separate with some other frameworks, so I was just sort of mirroring that. I only actually had use for the Replicate one, but figured I'd add both for completeness. Could go either way.

@akropp
Copy link
Contributor Author

akropp commented Dec 12, 2023

Hm. Perceptron test is failing on MacOS. Is this a known issue? Obviously not related to this commit. And it succeeds on my local machine (which is MacOS, and same Armadillo version) for what it's worth.

@akropp
Copy link
Contributor Author

akropp commented Dec 13, 2023

Is the perceptron test failing on other branches?

2023-12-13T17:58:25.0665010Z -------------------------------------------------------------------------------
2023-12-13T17:58:25.0665220Z IncrementalTrainingTest
2023-12-13T17:58:25.0665540Z -------------------------------------------------------------------------------
2023-12-13T17:58:25.0665820Z /Users/runner/work/1/s/src/mlpack/tests/perceptron_test.cpp:289
2023-12-13T17:58:25.0666070Z ...............................................................................
2023-12-13T17:58:25.0666180Z 
2023-12-13T17:58:25.0666360Z /Users/runner/work/1/s/src/mlpack/tests/perceptron_test.cpp:319: FAILED:
2023-12-13T17:58:25.0666670Z   REQUIRE( !approx_equal(p1.Weights(), p2.Weights(), "absdiff", 1e-5) )
2023-12-13T17:58:25.0666850Z with expansion:
2023-12-13T17:58:25.0667000Z   false

This is on the MacOS builds. Doesn't fail on my mac with same armadillo version.

@akropp
Copy link
Contributor Author

akropp commented Jan 6, 2024

When the decision_tree_regressor test fails, this is the output:

/home/vsts/work/1/s/src/mlpack/tests/decision_tree_regressor_test.cpp:955: FAILED:
REQUIRE( rmse < 6.1 )
with expansion:
6.1651240525 < 6.1

Any idea of 6.1 was chosen with some mathematical reasoning (as opposed to empirically chosen)? If not, any objection to changing it to 6.2?

@rcurtin
Copy link
Member

rcurtin commented Jan 6, 2024

Sorry, forgot to mention it here, but I opened #3594 to fix the decision tree regressor issues. If I had to guess, the tolerance was originally 6.0 (set somewhat arbitrarily by observation), then bumped to 6.1, and I think in #3594 I bumped to 6.2 and/or allowed multiple trials for it. Anyway, there were no failures in that test suite in 1000 trials, so if you merge master into this branch, at least that test should be fixed. :)

@akropp akropp requested a review from shrit January 8, 2024 14:15
Copy link
Member

@shrit shrit left a comment

Choose a reason for hiding this comment

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

Looks good to me 👍

Comment on lines 166 to 174
template<typename MatType>
struct GetUIntColType
{
typedef typename MatType::elem_type eT;
typedef typename std::conditional<
std::is_same<eT, arma::uword>::value, eT, arma::uword>::type elem;
typedef arma::Col<elem> type;
};

Copy link
Member

Choose a reason for hiding this comment

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

@rcurtin I tried this, I do not know if you might like it or not

Regspace should be used on vectors, however, in the following we were
assigning it to a matrix instead and then calling reshape.
Now when using templates this is no longer possible, therefore we need
to explicitly call conv_to to convert it from col to matrix.

Signed-off-by: Omar Shrit <[email protected]>
Copy link
Member

@rcurtin rcurtin left a comment

Choose a reason for hiding this comment

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

@shrit just some minor comments. If you can handle those then from my side I think everything is ready to merge. @akropp sorry this has been held up so long, thanks again for the implementation! I know we made a couple of changes after you were done so let us know if we accidentally broke any of your ideas or anything.

Signed-off-by: Omar Shrit <[email protected]>
@shrit shrit merged commit 1edb179 into mlpack:master Jan 28, 2024
This was referenced May 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants