# -*- coding: utf-8 -*-
"""
Implementation of Gate Recurrent Unit for lyrics prediction

@author: mayao
"""
import d2lzh as d2l
from mxnet import nd
from mxnet.gluon import rnn

(corpus_indices, char_to_idx, idx_to_char,
 vocab_size) = d2l.load_data_jay_lyrics()

num_inputs, num_hiddens, num_outputs = vocab_size, 256, vocab_size
ctx = d2l.try_gpu()

#Settings
num_epochs, num_steps, batch_size, lr, clipping_theta = 160, 35, 32, 1e2, 1e-2
pred_period, pred_len, prefixes = 40, 50, ['分开', '不分开']


#Training and predicting 
gru_layer = rnn.GRU(num_hiddens)
model = d2l.RNNModel(gru_layer, vocab_size)
d2l.train_and_predict_rnn_gluon(model, num_hiddens, vocab_size, ctx,
                                corpus_indices, idx_to_char, char_to_idx,
                                num_epochs, num_steps, lr, clipping_theta,
                                batch_size, pred_period, pred_len, prefixes)

8719928b862b16a2d4b1082cbfdad339783b20be
<mask token>

<mask token>
d2l.train_and_predict_rnn_gluon(model, num_hiddens, vocab_size, ctx,
    corpus_indices, idx_to_char, char_to_idx, num_epochs, num_steps, lr,
    clipping_theta, batch_size, pred_period, pred_len, prefixes)

<mask token>
corpus_indices, char_to_idx, idx_to_char, vocab_size = (d2l.
    load_data_jay_lyrics())
num_inputs, num_hiddens, num_outputs = vocab_size, 256, vocab_size
ctx = d2l.try_gpu()
num_epochs, num_steps, batch_size, lr, clipping_theta = (160, 35, 32, 100.0,
    0.01)
pred_period, pred_len, prefixes = 40, 50, ['分开', '不分开']
gru_layer = rnn.GRU(num_hiddens)
model = d2l.RNNModel(gru_layer, vocab_size)
d2l.train_and_predict_rnn_gluon(model, num_hiddens, vocab_size, ctx,
    corpus_indices, idx_to_char, char_to_idx, num_epochs, num_steps, lr,
    clipping_theta, batch_size, pred_period, pred_len, prefixes)

<mask token>
import d2lzh as d2l
from mxnet import nd
from mxnet.gluon import rnn
corpus_indices, char_to_idx, idx_to_char, vocab_size = (d2l.
    load_data_jay_lyrics())
num_inputs, num_hiddens, num_outputs = vocab_size, 256, vocab_size
ctx = d2l.try_gpu()
num_epochs, num_steps, batch_size, lr, clipping_theta = (160, 35, 32, 100.0,
    0.01)
pred_period, pred_len, prefixes = 40, 50, ['分开', '不分开']
gru_layer = rnn.GRU(num_hiddens)
model = d2l.RNNModel(gru_layer, vocab_size)
d2l.train_and_predict_rnn_gluon(model, num_hiddens, vocab_size, ctx,
    corpus_indices, idx_to_char, char_to_idx, num_epochs, num_steps, lr,
    clipping_theta, batch_size, pred_period, pred_len, prefixes)

# -*- coding: utf-8 -*-
"""
Implementation of Gate Recurrent Unit for lyrics prediction

@author: mayao
"""
import d2lzh as d2l
from mxnet import nd
from mxnet.gluon import rnn

(corpus_indices, char_to_idx, idx_to_char,
 vocab_size) = d2l.load_data_jay_lyrics()

num_inputs, num_hiddens, num_outputs = vocab_size, 256, vocab_size
ctx = d2l.try_gpu()

#Settings
num_epochs, num_steps, batch_size, lr, clipping_theta = 160, 35, 32, 1e2, 1e-2
pred_period, pred_len, prefixes = 40, 50, ['分开', '不分开']


#Training and predicting 
gru_layer = rnn.GRU(num_hiddens)
model = d2l.RNNModel(gru_layer, vocab_size)
d2l.train_and_predict_rnn_gluon(model, num_hiddens, vocab_size, ctx,
                                corpus_indices, idx_to_char, char_to_idx,
                                num_epochs, num_steps, lr, clipping_theta,
                                batch_size, pred_period, pred_len, prefixes)
