AI-MXNet
view release on metacpan or search on metacpan
lib/AI/MXNet/NDArray.pm view on Meta::CPAN
}
@$cur_shape = ((1)x(@$shape - @$cur_shape), @$cur_shape);
my $cur_shape_arr = pdl($cur_shape);
my $broadcasting_axes = ($cur_shape_arr != pdl($shape))->which->unpdl;
if (grep { $cur_shape->[$_] != 1 } @$broadcasting_axes)
{
confess($err_str);
}
if(join(',',@$cur_shape) ne join(',',@{ $self->shape }))
{
return __PACKAGE__->SUPER::broadcast_to($self->reshape($cur_shape),{ shape => $shape });
}
else
{
return __PACKAGE__->SUPER::broadcast_to($self, { shape => $shape });
}
}
=head2 wait_to_read
Block until all pending write operations on the NDArray are finished.
This function will return when all the pending writes to the current
NDArray are finished. There can be pending reads going on when the
function returns.
lib/AI/MXNet/RNN/Cell.pm view on Meta::CPAN
);
assert(
(not $self->base_cell->isa('AI::MXNet::RNN::SequentialCell') or not $self->_bidirectional),
"Bidirectional SequentialCell doesn't support zoneout. ".
"Please add ZoneoutCell to the cells underneath instead."
);
}
method reset()
{
$self->SUPER::reset;
$self->prev_output(undef);
}
method call(AI::MXNet::Symbol $inputs, SymbolOrArrayOfSymbols $states)
{
my ($cell, $p_outputs, $p_states) = ($self->base_cell, $self->zoneout_outputs, $self->zoneout_states);
my ($next_output, $next_states) = &{$cell}($inputs, $states);
my $mask = sub {
my ($p, $like) = @_;
AI::MXNet::Symbol->Dropout(
lib/AI/MXNet/RecordIO.pm view on Meta::CPAN
flag : str
'w' for write or 'r' for read
=cut
has 'idx_path' => (is => 'ro', isa => 'Str', required => 1);
has [qw/idx
keys fidx/] => (is => 'rw', init_arg => undef);
method open()
{
$self->SUPER::open();
$self->idx({});
$self->keys([]);
open(my $f, $self->flag eq 'r' ? '<' : '>', $self->idx_path);
$self->fidx($f);
if(not $self->writable)
{
while(<$f>)
{
chomp;
my ($key, $val) = split(/\t/);
push @{ $self->keys }, $key;
$self->idx->{$key} = $val;
}
}
}
method close()
{
return if not $self->is_open;
$self->SUPER::close();
$self->fidx(undef);
}
=head2 seek
Query current read head position.
=cut
method seek(Int $idx)
{
lib/AI/MXNet/Symbol/NameManager.pm view on Meta::CPAN
=cut
has prefix => (
is => 'ro',
isa => 'Str',
required => 1
);
method get(Maybe[Str] $name, Str $hint)
{
$name = $self->SUPER::get($name, $hint);
return $self->prefix . $name;
}
1;
( run in 0.985 second using v1.01-cache-2.11-cpan-49f99fa48dc )