se;
use AI::MXNet::NS;
use AI::MXNet::Base qw(:DEFAULT pzeros pceil);
use AI::MXNet::NDArray;
use JSON::PP;
use overload "&{}" => sub { my $self = shift; sub { $self->call(@_) } },
'""'
my $self = shift;
my ($name) = ref($self) =~ /::(\w+)$/;
encode_json(
[lc $name,
$self->kwargs//{ map { $_ => "".$self->$_
$kwargs = {};
}
else
{
($klass, $kwargs) = @{ decode_json($init) };
}
$self->get_init_registry->{ lc $klass }->new(%{ $kwargs })->_init_wei
$x, @args)
{
confess("NotImplementedError");
}
=head2 export
Export HybridBlock to json format that can be loaded by AI::MXNet::Module
or the C++ interface.
When there
ers
----------
$path : str
Path to save model. Two files 'path-symbol.json' and 'path-xxxx.params'
will be created, where xxxx is the 4 digits epoch number.
g export."
);
}
my $sym = $self->_cached_graph->[1];
$sym->save("$path-symbol.json");
my %arg_names = map { $_ => 1 } @{ $sym->list_arguments };
my %aux_names = map { $_ =
oning)
{
return $self->tojson();
}
method STORABLE_thaw($cloning, $json)
{
my $handle = check_call(
AI::MXNetCAPI::SymbolCreateFromJSON(
$json
)
);
$self->
ame));
}
=head2 tojson
Save the symbol into a JSON string.
See Also
--------
load_json : Used to load symbol from JSON string.
=cut
method tojson()
{
return sca
lar(check_call(AI::MXNetCAPI::SymbolSaveToJSON($self->handle)));
}
method _get_ndarray_inputs(
Str $arg_key,
HashRef[AI::MXNet::NDArray]|A
ad_checkpoint(Str $prefix, Int $epoch)
{
my $symbol = AI::MXNet::Symbol->load("$prefix-symbol.json");
my %save_dict = %{ AI::MXNet::NDArray->load(sprintf('%s-%04d.params', $prefix, $epoch)) };
ix : Str
path prefix of saved model files. You should have
"prefix-symbol.json", "prefix-xxxx.params", and
optionally "prefix-xxxx.states", where xxxx is the
tr $prefix, Int $epoch, Bool $save_optimizer_states=0)
{
$self->_symbol->save("$prefix-symbol.json");
my $param_name = sprintf('%s-%04d.params', $prefix, $epoch);
$self->save_params($param
, hash ref of name to NDArray of net's auxiliary states.
Notes
-----
- prefix-symbol.json will be saved for symbol.
- prefix-epoch.params will be saved for parameters.
=cut
method sa
ay of net's auxiliary states.
Notes
-----
- symbol will be loaded from prefix-symbol.json.
- parameters will be loaded from prefix-epoch.params.
=cut
method load_rnn_checkpoint(
rnings;
use AI::MXNet::NS;
use AI::MXNet::Function::Parameters;
use Scalar::Util qw/blessed/;
use JSON::PP;
=encoding utf-8
=head1 NAME
AI::MXNet::Metric - Evaluation Metric API.
=head1 DESCRIP
;
}
if($metric =~ /^{/ and not @kwargs)
{
my $config = decode_json($metric);
$metric = delete $config->{metric};
@kwargs = %{ $config };
t;
use warnings;
use AI::MXNet::NS;
use AI::MXNet::Base;
use AI::MXNet::Function::Parameters;
use JSON::PP;
=encoding UTF-8
=head1 NAME
AI::MXNet::Vizualization - Vizualization support for Perl
hape_dict{ @{ $interals->list_outputs } } = @{ $out_shapes };
}
my $conf = decode_json($symbol->tojson);
my $nodes = $conf->{nodes};
my %heads = map { $_ => 1 } @{ $conf->{heads}[0] };
hape_dict{ @{ $interals->list_outputs } } = @{ $out_shapes };
}
my $conf = decode_json($symbol->tojson);
my $nodes = $conf->{nodes};
my %node_attr = (
qw/ shape box fixedsize t