NAME
AI::MXNet::Vizualization - Vizualization support
for
Perl interface to MXNet machine learning library
SYNOPSIS
use
strict;
use
warnings;
### model
my
$data
= mx->symbol->Variable(
'data'
);
my
$conv1
= mx->symbol->Convolution(
data
=>
$data
,
name
=>
'conv1'
,
num_filter
=> 32,
kernel
=> [3,3],
stride
=> [2,2]);
my
$bn1
= mx->symbol->BatchNorm(
data
=>
$conv1
,
name
=>
"bn1"
);
my
$act1
= mx->symbol->Activation(
data
=>
$bn1
,
name
=>
'relu1'
,
act_type
=>
"relu"
);
my
$mp1
= mx->symbol->Pooling(
data
=>
$act1
,
name
=>
'mp1'
,
kernel
=> [2,2],
stride
=>[2,2],
pool_type
=>
'max'
);
my
$conv2
= mx->symbol->Convolution(
data
=>
$mp1
,
name
=>
'conv2'
,
num_filter
=> 32,
kernel
=>[3,3],
stride
=>[2,2]);
my
$bn2
= mx->symbol->BatchNorm(
data
=>
$conv2
,
name
=>
"bn2"
);
my
$act2
= mx->symbol->Activation(
data
=>
$bn2
,
name
=>
'relu2'
,
act_type
=>
"relu"
);
my
$mp2
= mx->symbol->Pooling(
data
=>
$act2
,
name
=>
'mp2'
,
kernel
=>[2,2],
stride
=>[2,2],
pool_type
=>
'max'
);
my
$fl
= mx->symbol->Flatten(
data
=>
$mp2
,
name
=>
"flatten"
);
my
$fc1
= mx->symbol->FullyConnected(
data
=>
$fl
,
name
=>
"fc1"
,
num_hidden
=>30);
my
$act3
= mx->symbol->Activation(
data
=>
$fc1
,
name
=>
'relu3'
,
act_type
=>
"relu"
);
my
$fc2
= mx->symbol->FullyConnected(
data
=>
$act3
,
name
=>
'fc2'
,
num_hidden
=>10);
my
$softmax
= mx->symbol->SoftmaxOutput(
data
=>
$fc2
,
name
=>
'softmax'
);
## creates the image file working directory
mx->viz->plot_network(
$softmax
,
save_format
=>
'png'
)->render(
"network.png"
);
DESCRIPTION
Vizualization support
for
Perl interface to MXNet machine learning library
Class methods
print_summary
convert symbol
for
detail information
Parameters
----------
symbol: AI::MXNet::Symbol
symbol to be visualized
shape: hashref
hashref of shapes, str->shape (arrayref[
int
]),
given
input shapes
line_length:
int
total
length
of printed lines
positions: arrayref[float]
relative or absolute positions of
log
elements in
each
line
Returns
------
nothing
plot_network
convert symbol to dot object
for
visualization
Parameters
----------
title: str
title of the dot graph
symbol: AI::MXNet::Symbol
symbol to be visualized
shape: HashRef[Shape]
If supplied, the visualization will include the shape
of
each
tensor on the edges between nodes.
node_attrs: HashRef of node's attributes
for
example:
{
shape
=>
"oval"
,
fixedsize
=>
"false"
}
means to plot the network in
"oval"
hide_weights: Bool
if
True (
default
) then inputs
with
names like `
*_weight
`
or `
*_bias
` will be hidden
Returns
------
dot: Diagraph
dot object of symbol