Skip to content

Conversation

@helinwang
Copy link
Contributor

No description provided.

Copy link
Contributor

@sidgoyal78 sidgoyal78 Apr 30, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we maybe have something like fluid.params.load() (since we have trainer.params.save() above) ?

Copy link
Contributor Author

@helinwang helinwang May 1, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for thinking about it! If we aim for symmetry, params.save is a method of a params instance, in the same time fluid.params.load is a static method, which is not very symmetric?

cs2be
cs2be previously approved these changes May 1, 2018
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry didn't catch this before, but place is not used, it should be passed into fluid.Inferencer

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, done.

next_word = fluid.layers.data(name='nextw', shape=[1], dtype='int64')
predict_word = inference_network()
cost = fluid.layers.cross_entropy(input=predict_word, label=next_word)
avg_cost = fluid.layers.mean(cost)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The metrics, like error rate, auc, are not defined in this demo. How do we define a error rate in our new designed API?

By just adding fluid.layers.accury(input=predict_word, label=label) ? Should we fetch metrics by default?


trainer = fluid.Trainer(
partial(inference_network, is_sparse),
fluid.optimizer.SGD(learning_rate=0.001),
Copy link
Collaborator

@reyoung reyoung May 2, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we passing the optimizer instance to a trainer, we cannot use learning rate schedule since the learning_rate is a variable of learning rate schedule method, which is designed by @jacquesqiao

Perhaps, we can pass a lambda here or an instance here.

lambda could be

trainer = fluid.Trainer(optimizer=lambda: fluid.optimizer.SGD(learning_rate=fluid.layers.fill_constant(1e-3)))

Copy link
Contributor Author

@helinwang helinwang May 3, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool! I realized that we may need to freeze parameter when reading your GAN example.
Another possibility is we pass in a optimize function?

def optimize(loss):
    opt = fluid.optimizer.SGD(learning_rate=fluid.layers.fill_constant(1e-3)))
    return opt.minimize(
        loss=loss,
        parameter_list=[
            p.name for p in g_program.global_block().all_parameters()
        ])

trainer = fluid.Trainer(..., optimize=optimize)

EDIT: never mind, I just realized that the user would not have access to p.name for p in g_program.global_block().all_parameters().

sys.exit("got NaN loss, training failed.")

trainer = fluid.Trainer(
partial(inference_network, is_sparse),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

partial(train_network, is_sparse) ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, fluid.Trainer's first argument should be a function without any arguments. partial(train_network, is_sparse) binds is_sparse to train_network, creating a function without any argument.

@helinwang helinwang merged commit a785a83 into PaddlePaddle:develop May 2, 2018
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

Successfully merging this pull request may close these issues.

4 participants