From aea096f55f85ad7fc3c21dd098436fe455af327d Mon Sep 17 00:00:00 2001 From: Chiyuan Zhang Date: Sun, 15 Nov 2015 20:30:04 -0500 Subject: [PATCH] use a smaller network for visualization. --- docs/tutorial/images/char-lstm-vis.svg | 1284 ++++++------------------ examples/char-lstm/visualize.jl | 4 +- 2 files changed, 303 insertions(+), 985 deletions(-) diff --git a/docs/tutorial/images/char-lstm-vis.svg b/docs/tutorial/images/char-lstm-vis.svg index cf49d097bdc7..610abab774b7 100644 --- a/docs/tutorial/images/char-lstm-vis.svg +++ b/docs/tutorial/images/char-lstm-vis.svg @@ -4,1114 +4,432 @@ - - + + Network Visualization - - -ptb_embed_3 - -ptb_embed_3 -FullyConnected -num-hidden=256 - - -ptb_lstm_3_i2h - -ptb_lstm_3_i2h -FullyConnected -num-hidden=1024 - - -ptb_lstm_3_i2h->ptb_embed_3 - - - - -_mul14 - -_mul14 -_Mul - - -ptb_lstm_3_i2h->_mul14 - - - + -ptb_embed_2 - -ptb_embed_2 -FullyConnected -num-hidden=256 +ptb_embed_2 + +ptb_embed_2 +FullyConnected +num-hidden=256 -ptb_lstm_2_i2h - -ptb_lstm_2_i2h -FullyConnected -num-hidden=1024 +ptb_lstm_2_i2h + +ptb_lstm_2_i2h +FullyConnected +num-hidden=1024 -ptb_lstm_2_i2h->ptb_embed_2 - - - - -_mul8 - -_mul8 -_Mul - - -ptb_lstm_2_i2h->_mul8 - - +ptb_lstm_2_i2h->ptb_embed_2 + + -ptb_embed_1 - -ptb_embed_1 -FullyConnected -num-hidden=256 +ptb_embed_1 + +ptb_embed_1 +FullyConnected +num-hidden=256 -ptb_lstm_1_i2h - -ptb_lstm_1_i2h -FullyConnected -num-hidden=1024 +ptb_lstm_1_i2h + +ptb_lstm_1_i2h +FullyConnected +num-hidden=1024 -ptb_lstm_1_i2h->ptb_embed_1 - - - - -_mul2 - -_mul2 -_Mul - - -ptb_lstm_1_i2h->_mul2 - - +ptb_lstm_1_i2h->ptb_embed_1 + + -ptb_lstm_1_h2h - -ptb_lstm_1_h2h -FullyConnected -num-hidden=1024 +ptb_lstm_1_h2h + +ptb_lstm_1_h2h +FullyConnected +num-hidden=1024 -_plus0 - -_plus0 -_Plus +_plus0 + +_plus0 +_Plus -_plus0->ptb_lstm_1_i2h - - +_plus0->ptb_lstm_1_i2h + + -_plus0->ptb_lstm_1_h2h - - +_plus0->ptb_lstm_1_h2h + + -ptb_lstm_1_gates - -ptb_lstm_1_gates -SliceChannel +ptb_lstm_1_gates + +ptb_lstm_1_gates +SliceChannel -ptb_lstm_1_gates->_plus0 - - - - -_plus2 - -_plus2 -_Plus - - -ptb_lstm_1_gates->_plus2 - - +ptb_lstm_1_gates->_plus0 + + -activation3 - -activation3 -Activation -act-type=sigmoid +activation3 + +activation3 +Activation +act-type=sigmoid -activation3->ptb_lstm_1_gates - - +activation3->ptb_lstm_1_gates + + -activation2 - -activation2 -Activation -act-type=sigmoid +activation2 + +activation2 +Activation +act-type=sigmoid -activation2->ptb_lstm_1_gates - - +activation2->ptb_lstm_1_gates + + -_mul0 - -_mul0 -_Mul +_mul0 + +_mul0 +_Mul -_mul0->activation2 - - +_mul0->activation2 + + -activation0 - -activation0 -Activation -act-type=sigmoid +activation0 + +activation0 +Activation +act-type=sigmoid -activation0->ptb_lstm_1_gates - - +activation0->ptb_lstm_1_gates + + -activation1 - -activation1 -Activation -act-type=tanh +activation1 + +activation1 +Activation +act-type=tanh -activation1->ptb_lstm_1_gates - - +activation1->ptb_lstm_1_gates + + -_mul1 - -_mul1 -_Mul +_mul1 + +_mul1 +_Mul -_mul1->activation0 - - +_mul1->activation0 + + -_mul1->activation1 - - +_mul1->activation1 + + -_plus1 - -_plus1 -_Plus +_plus1 + +_plus1 +_Plus -_plus1->_mul0 - - +_plus1->_mul0 + + -_plus1->_mul1 - - +_plus1->_mul1 + + -activation4 - -activation4 -Activation -act-type=tanh +activation4 + +activation4 +Activation +act-type=tanh -activation4->_plus1 - - +activation4->_plus1 + + + + +_mul2 + +_mul2 +_Mul -_mul2->activation3 - - +_mul2->activation3 + + -_mul2->activation4 - - +_mul2->activation4 + + -ptb_lstm_2_h2h - -ptb_lstm_2_h2h -FullyConnected -num-hidden=1024 +ptb_lstm_2_h2h + +ptb_lstm_2_h2h +FullyConnected +num-hidden=1024 -ptb_lstm_2_h2h->_mul2 - - +ptb_lstm_2_h2h->_mul2 + + - -_mul5 - -_mul5 -_Mul - - -ptb_lstm_2_h2h->_mul5 - - - - -_plus4 - -_plus4 -_Plus - - -_plus4->ptb_lstm_2_i2h - - - - -_plus4->ptb_lstm_2_h2h - - + +_plus2 + +_plus2 +_Plus + + +_plus2->ptb_lstm_2_i2h + + + + +_plus2->ptb_lstm_2_h2h + + -ptb_lstm_2_gates - -ptb_lstm_2_gates -SliceChannel - - -ptb_lstm_2_gates->_plus4 - - - - -_plus6 - -_plus6 -_Plus - - -ptb_lstm_2_gates->_plus6 - - - - -activation13 - -activation13 -Activation -act-type=sigmoid - - -activation13->ptb_lstm_2_gates - - - - -activation12 - -activation12 -Activation -act-type=sigmoid - - -activation12->ptb_lstm_2_gates - - - - -_mul6 - -_mul6 -_Mul - - -_mul6->_plus1 - - - - -_mul6->activation12 - - - - -activation10 - -activation10 -Activation -act-type=sigmoid - - -activation10->ptb_lstm_2_gates - - - - -activation11 - -activation11 -Activation -act-type=tanh - - -activation11->ptb_lstm_2_gates - - - - -_mul7 - -_mul7 -_Mul - - -_mul7->activation10 - - - - -_mul7->activation11 - - - - -_plus5 - -_plus5 -_Plus - - -_plus5->_mul6 - - - - -_plus5->_mul7 - - - - -activation14 - -activation14 -Activation -act-type=tanh - - -activation14->_plus5 - - - - -_mul8->activation13 - - - - -_mul8->activation14 - - - - -ptb_lstm_3_h2h - -ptb_lstm_3_h2h -FullyConnected -num-hidden=1024 - - -ptb_lstm_3_h2h->_mul8 - - - - -_mul11 - -_mul11 -_Mul - - -ptb_lstm_3_h2h->_mul11 - - - - -_plus8 - -_plus8 -_Plus - - -_plus8->ptb_lstm_3_i2h - - - - -_plus8->ptb_lstm_3_h2h - - - - -ptb_lstm_3_gates - -ptb_lstm_3_gates -SliceChannel - - -ptb_lstm_3_gates->_plus8 - - - - -_plus10 - -_plus10 -_Plus - - -ptb_lstm_3_gates->_plus10 - - - - -activation23 - -activation23 -Activation -act-type=sigmoid - - -activation23->ptb_lstm_3_gates - - - - -activation22 - -activation22 -Activation -act-type=sigmoid - - -activation22->ptb_lstm_3_gates - - - - -_mul12 - -_mul12 -_Mul - - -_mul12->_plus5 - - - - -_mul12->activation22 - - - - -activation20 - -activation20 -Activation -act-type=sigmoid - - -activation20->ptb_lstm_3_gates - - - - -activation21 - -activation21 -Activation -act-type=tanh - - -activation21->ptb_lstm_3_gates - - - - -_mul13 - -_mul13 -_Mul - - -_mul13->activation20 - - - - -_mul13->activation21 - - - - -_plus9 - -_plus9 -_Plus - - -_plus9->_mul12 - - - - -_plus9->_mul13 - - - - -activation24 - -activation24 -Activation -act-type=tanh - - -activation24->_plus9 - - - - -_mul14->activation23 - - - - -_mul14->activation24 - - - - -_plus2->ptb_lstm_1_i2h - - - - -_plus2->ptb_lstm_1_h2h - - +ptb_lstm_2_gates + +ptb_lstm_2_gates +SliceChannel + + +ptb_lstm_2_gates->_plus2 + + -activation8 - -activation8 -Activation -act-type=sigmoid +activation8 + +activation8 +Activation +act-type=sigmoid - -activation8->ptb_lstm_1_gates - - + +activation8->ptb_lstm_2_gates + + -activation7 - -activation7 -Activation -act-type=sigmoid +activation7 + +activation7 +Activation +act-type=sigmoid - -activation7->ptb_lstm_1_gates - - + +activation7->ptb_lstm_2_gates + + -_mul3 - -_mul3 -_Mul +_mul3 + +_mul3 +_Mul + + +_mul3->_plus1 + + -_mul3->activation7 - - +_mul3->activation7 + + -activation5 - -activation5 -Activation -act-type=sigmoid +activation5 + +activation5 +Activation +act-type=sigmoid - -activation5->ptb_lstm_1_gates - - + +activation5->ptb_lstm_2_gates + + -activation6 - -activation6 -Activation -act-type=tanh +activation6 + +activation6 +Activation +act-type=tanh - -activation6->ptb_lstm_1_gates - - + +activation6->ptb_lstm_2_gates + + -_mul4 - -_mul4 -_Mul +_mul4 + +_mul4 +_Mul -_mul4->activation5 - - +_mul4->activation5 + + -_mul4->activation6 - - +_mul4->activation6 + + -_plus3 - -_plus3 -_Plus +_plus3 + +_plus3 +_Plus -_plus3->_mul3 - - +_plus3->_mul3 + + -_plus3->_mul4 - - +_plus3->_mul4 + + -activation9 - -activation9 -Activation -act-type=tanh +activation9 + +activation9 +Activation +act-type=tanh -activation9->_plus3 - - +activation9->_plus3 + + + + +_mul5 + +_mul5 +_Mul -_mul5->activation8 - - +_mul5->activation8 + + -_mul5->activation9 - - - - -_plus6->ptb_lstm_2_i2h - - - - -_plus6->ptb_lstm_2_h2h - - - - -activation18 - -activation18 -Activation -act-type=sigmoid - - -activation18->ptb_lstm_2_gates - - - - -activation17 - -activation17 -Activation -act-type=sigmoid - - -activation17->ptb_lstm_2_gates - - - - -_mul9 - -_mul9 -_Mul - - -_mul9->_plus3 - - - - -_mul9->activation17 - - - - -activation15 - -activation15 -Activation -act-type=sigmoid - - -activation15->ptb_lstm_2_gates - - - - -activation16 - -activation16 -Activation -act-type=tanh - - -activation16->ptb_lstm_2_gates - - - - -_mul10 - -_mul10 -_Mul - - -_mul10->activation15 - - - - -_mul10->activation16 - - - - -_plus7 - -_plus7 -_Plus - - -_plus7->_mul9 - - - - -_plus7->_mul10 - - - - -activation19 - -activation19 -Activation -act-type=tanh - - -activation19->_plus7 - - - - -_mul11->activation18 - - - - -_mul11->activation19 - - - - -_plus10->ptb_lstm_3_i2h - - - - -_plus10->ptb_lstm_3_h2h - - - - -activation28 - -activation28 -Activation -act-type=sigmoid - - -activation28->ptb_lstm_3_gates - - - - -activation27 - -activation27 -Activation -act-type=sigmoid - - -activation27->ptb_lstm_3_gates - - - - -_mul15 - -_mul15 -_Mul - - -_mul15->_plus7 - - - - -_mul15->activation27 - - - - -activation25 - -activation25 -Activation -act-type=sigmoid - - -activation25->ptb_lstm_3_gates - - - - -activation26 - -activation26 -Activation -act-type=tanh - - -activation26->ptb_lstm_3_gates - - - - -_mul16 - -_mul16 -_Mul - - -_mul16->activation25 - - - - -_mul16->activation26 - - - - -_plus11 - -_plus11 -_Plus - - -_plus11->_mul15 - - - - -_plus11->_mul16 - - - - -activation29 - -activation29 -Activation -act-type=tanh - - -activation29->_plus11 - - - - -_mul17 - -_mul17 -_Mul - - -_mul17->activation28 - - - - -_mul17->activation29 - - - - -ptb_l2_last_h - -ptb_l2_last_h -BlockGrad - - -ptb_l2_last_h->_mul17 - - +_mul5->activation9 + + -ptb_l1_last_h - -ptb_l1_last_h -BlockGrad - - -ptb_l1_last_h->_mul14 - - - - -ptb_l2_last_c - -ptb_l2_last_c -BlockGrad - - -ptb_l2_last_c->_plus11 - - +ptb_l1_last_h + +ptb_l1_last_h +BlockGrad + + +ptb_l1_last_h->_mul5 + + -ptb_l1_last_c - -ptb_l1_last_c -BlockGrad - - -ptb_l1_last_c->_plus9 - - - - -ptb_pred_3 - -ptb_pred_3 -FullyConnected -num-hidden=128 - - -ptb_pred_3->_mul17 - - - - -ptb_softmax_3 - -ptb_softmax_3 -SoftmaxOutput - - -ptb_softmax_3->ptb_pred_3 - - +ptb_l1_last_c + +ptb_l1_last_c +BlockGrad + + +ptb_l1_last_c->_plus3 + + -ptb_pred_2 - -ptb_pred_2 -FullyConnected -num-hidden=128 +ptb_pred_2 + +ptb_pred_2 +FullyConnected +num-hidden=128 - -ptb_pred_2->_mul11 - - + +ptb_pred_2->_mul5 + + -ptb_softmax_2 - -ptb_softmax_2 -SoftmaxOutput +ptb_softmax_2 + +ptb_softmax_2 +SoftmaxOutput -ptb_softmax_2->ptb_pred_2 - - +ptb_softmax_2->ptb_pred_2 + + -ptb_pred_1 - -ptb_pred_1 -FullyConnected -num-hidden=128 +ptb_pred_1 + +ptb_pred_1 +FullyConnected +num-hidden=128 - -ptb_pred_1->_mul5 - - + +ptb_pred_1->_mul2 + + -ptb_softmax_1 - -ptb_softmax_1 -SoftmaxOutput +ptb_softmax_1 + +ptb_softmax_1 +SoftmaxOutput -ptb_softmax_1->ptb_pred_1 - - +ptb_softmax_1->ptb_pred_1 + + diff --git a/examples/char-lstm/visualize.jl b/examples/char-lstm/visualize.jl index 336afea30705..acf757515005 100644 --- a/examples/char-lstm/visualize.jl +++ b/examples/char-lstm/visualize.jl @@ -3,8 +3,8 @@ include(joinpath(dirname(@__FILE__), "lstm.jl")) using MXNet -vis_n_layer = 2 -vis_seq_len = 3 +vis_n_layer = 1 +vis_seq_len = 2 vis_n_class = 128 lstm = LSTM(vis_n_layer, vis_seq_len, DIM_HIDDEN, DIM_EMBED, vis_n_class, name=NAME, output_states=true)