AI-ML
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
lib/AI/ML/Expr.pm view on Meta::CPAN
$th::Lapack::Matrixref(1)m = lrelu($m, 0.0001);
$m = m->lrelu(0.1);
=cut
sub lrelu {
my ($self, $v) = @_;
return bless { package => __PACKAGE__, type => 'lrelu', args => [$self, $v] } => __PACKAGE__;
}
sub eval_lrelu {
my ($tree, $v) = @_;
if (ref($tree) eq "Math::Lapack::Matrix") {
return _bless _lrelu($tree->matrix_id, $v);
}
die "lReLU for non matrix";
}
=head2 d_lrelu
Allows apply the function d_lrelu to every element of the matrix.
$th::Lapack::Matrixref(1)m = lrelu($m, 0.0001);
$m = m->lrelu(0.1);
=cut
sub d_lrelu {
my ($self, $v) = @_;
return bless { package => __PACKAGE__, type => 'd_lrelu', args => [$self, $v] } => __PACKAGE__;
}
sub eval_d_lrelu {
my ($tree, $v) = @_;
if (ref($tree) eq "Math::Lapack::Matrix") {
return _bless _d_lrelu($tree->matrix_id, $v);
}
die "lReLU for non matrix";
}
=head2 softmax
Allows apply the function softmax to every element of the matrix.
$m = softmax($m);
$m = $m->softmax();
=cut
sub softmax {
my ($self) = @_;
return bless { package => __PACKAGE__, type => 'softmax', args => [$self] } => __PACKAGE__;
}
sub eval_softmax {
my $tree = shift;
if (ref($tree) eq "Math::Lapack::Matrix") {
my $s = $tree->max();
my $e_x = exp( $tree - $s );
my $div = sum( $e_x, 1 );
return $e_x / $div;
#use Data::Dumper;
#print STDERR Dumper $matrix;
# return _bless _softmax($tree->matrix_id);
}
die "softmax for non matrix";
}
=head2 d_softmax
Allows apply the function d_softmax to every element of the matrix.
$m = d_softmax($m);
$m = $m->d_softmax();
=cut
sub d_softmax {
my ($self) = @_;
return bless { package => __PACKAGE__, type => 'd_softmax', args => [$self] } => __PACKAGE__;
}
sub eval_d_softmax {
my $tree = shift;
if (ref($tree) eq "Math::Lapack::Matrix") {
return _bless _d_softmax($tree->matrix_id);
}
die "d_softmax for non matrix";
}
=head2 tanh
Allows apply the function tanh to every element of the matrix.
$m = tanh($m);
$m = $m->tanh();
=cut
sub tanh {
my ($self) = @_;
return bless { package => __PACKAGE__, type => 'tanh', args => [$self] } => __PACKAGE__;
}
sub eval_tanh {
my $tree = shift;
if( ref($tree) eq "Math::Lapack::Matrix"){
return _bless _tanh($tree->matrix_id);
}
die "tanh for non matrix";
}
=head2 d_tanh
Allows apply the function d_tanh to every element of the matrix.
$m = d_tanh($m);
$m = $m->d_tanh();
=cut
sub d_tanh {
my ($self) = @_;
return bless { package => __PACKAGE__, type => 'd_tanh', args => [$self] } => __PACKAGE__;
}
sub eval_d_tanh {
my $tree = shift;
view all matches for this distributionview release on metacpan - search on metacpan
( run in 1.081 second using v1.00-cache-2.02-grep-82fe00e-cpan-9f2165ba459b )