AI-MXNet
view release on metacpan or search on metacpan
lib/AI/MXNet/Symbol.pm view on Meta::CPAN
return \%ret;
}
=head2 attr_dict
Recursively get all attributes from the symbol and its childrens
Returns
-------
ret : hash ref of str to hash ref.
Returns a dict whose keys are names of the symbol and its children.
Values of the returned dict are dictionaries that map attribute keys to values.
=cut
method attr_dict()
{
my %ret;
my @attrs = @{ check_call(AI::MXNetCAPI::SymbolListAttr($self->handle)) };
my $size = @attrs/2;
for (my $i = 0; $i < $size; $i++)
{
my ($name, $key) = split(/\$/, $attrs[$i*2]);
my $val = $attrs[$i*2+1];
$ret{ $name }{ $key } = $val;
}
return \%ret;
}
method _set_attr(Str @args)
{
my %kwargs = @args;
while(my ($key, $val) = each(%kwargs))
{
check_call(
AI::MXNetCAPI::SymbolSetAttr(
$self->handle, $key, $val
)
);
}
}
=head2 get_internals
Get a new grouped symbol whose output contains all the internal outputs of this symbol.
Returns
-------
sgroup : AI::MXNet::Symbol
The internal symbol of the symbol.
=cut
method get_internals()
{
my $handle = check_call(AI::MXNetCAPI::SymbolGetInternals($self->handle));
return __PACKAGE__->new(handle => $handle);
}
=head2 get_children
Get a new grouped symbol whose output contains
inputs to output nodes of the original symbol
Returns
-------
sgroup : Symbol or undef
The children of the head node. If the symbol has no
inputs undef will be returned.
=cut
method get_children()
{
my $handle = check_call(AI::MXNetCAPI::SymbolGetChildren($self->handle));
my $ret = __PACKAGE__->new(handle => $handle);
return undef unless @{ $ret->list_outputs };
return $ret;
}
=head2 list_arguments
List all the arguments in the symbol.
Returns
-------
args : array ref of strings
=cut
method list_arguments()
{
return scalar(check_call(AI::MXNetCAPI::SymbolListArguments($self->handle)));
}
=head2 list_outputs()
List all outputs in the symbol.
Returns
-------
$out : array ref of strings.
=cut
method list_outputs()
{
return scalar(check_call(AI::MXNetCAPI::SymbolListOutputs($self->handle)));
}
=head2 list_auxiliary_states()
List all auxiliary states in the symbol.
Returns
-------
aux_states : array ref of string
List the names of the auxiliary states.
Notes
-----
Auxiliary states are special states of symbols that do not corresponds to an argument,
and do not have gradient. But still be useful for the specific operations.
A common example of auxiliary state is the moving_mean and moving_variance in BatchNorm.
( run in 2.709 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )