Skip to content

Conversation

@dzhwinter
Copy link
Contributor

fix #2713

TensorToProto(*update_delta_, state.mutable_update_delta());
auto str = state.SerializeAsString();
*state_len = str.size();
*state_len += str.size();
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure why need to +=?

Copy link
Contributor Author

@dzhwinter dzhwinter Jul 5, 2017

Choose a reason for hiding this comment

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

because get the lr_state serialization length here.

std::string lr_str = this->lr_policy_->SerializeState(state_len)

use = will overwrite the lr_state length.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see.

Copy link
Contributor

@typhoonzero typhoonzero left a comment

Choose a reason for hiding this comment

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

LGTM++

TensorToProto(*update_delta_, state.mutable_update_delta());
auto str = state.SerializeAsString();
*state_len = str.size();
*state_len += str.size();
Copy link
Contributor

Choose a reason for hiding this comment

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

I see.

optional double learning_rate = 101;
optional double lr_decay_a = 102;
optional double lr_decay_b = 103;
optional LrPolicyState lr_state = 101;
Copy link
Contributor

Choose a reason for hiding this comment

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

Do not re-use protobuf ids to change the fields. Well, since we it's still under development, this is fine. When people are using this code, we need to consider the backward compatibility.

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 for the reminding. That's true when we maintain a project.
But what is the best practice of field number? Making the field number auto increment by 1 seems not a smart idea. By the way, the field number is only used by protoc compiler to represent an entry of protobuf. Even though protobuf support indexed value by field number, but it should not be used in user's code. Did you ever run into such a code base?

Copy link
Contributor

Choose a reason for hiding this comment

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

Once the protobuf index is used by messages, it should never change for compatibility, for the old client or somewhere is still using the old .proto generated code.

  1. Do not change the current index
  2. Only append field not modify them.

@dzhwinter dzhwinter merged commit 6398c15 into PaddlePaddle:develop Jul 9, 2017
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.

Optimizer Learning Rate Policy save state.

2 participants