Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Many to one, how to set 'max_grad_norm' #20

Closed
cobnut opened this issue Nov 11, 2016 · 3 comments
Closed

Many to one, how to set 'max_grad_norm' #20

cobnut opened this issue Nov 11, 2016 · 3 comments

Comments

@cobnut
Copy link

cobnut commented Nov 11, 2016

Many to one, like this, but i don't know how to set 'max_grad_norm' ? what's the meaning of 'max_grad_norm'? how to set 'max_grad_norm'?


network = tl.layers.DynamicRNNLayer(network,
                        cell_fn=tf.nn.rnn_cell.BasicLSTMCell,
                        cell_init_args={'forget_bias': 0.0, 'state_is_tuple': True},
                        n_hidden=hidden_size,
                        n_layer=2,
                        dropout=0.5,
                        initializer=tf.random_uniform_initializer(-init_scale, init_scale),
                        sequence_length = tl.layers.retrieve_seq_length_op2(inputs),
                        return_last=True,
                        name='dynamic_lstm_layer')
lstm = network
@zsdonghao
Copy link
Member

@narrator-wong you can find the example in PTB tutorials.

    grads, _ = tf.clip_by_global_norm(tf.gradients(cost, tvars),
                                      max_grad_norm)
    optimizer = tf.train.GradientDescentOptimizer(lr)
    train_op = optimizer.apply_gradients(zip(grads, tvars))

@cobnut
Copy link
Author

cobnut commented Nov 11, 2016

@zsdonghao Thanks...
i saw this, but i mean.. for example, set max_grad_norm = 10 or 20 or 50 ...? what's the difference?
i set 'max_grad_norm' according to my num_step?
if the num_step of my LSTM is 100, and my max_grad_norm also 100?

@zsdonghao
Copy link
Member

@narrator-wong Gitter may be the better place to discuss algorithm, we normally report bugs on Issues.

zsdonghao pushed a commit that referenced this issue May 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants