- Notifications
You must be signed in to change notification settings - Fork 5.9k
init beamsearch wrapper #7952
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
init beamsearch wrapper #7952
Conversation
python/paddle/v2/fluid/layers/nn.py Outdated
| import __init__ as pd | ||
| | ||
| | ||
| class SequenceDecoder: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure if it's more appropriate to move the class to control_flow.py or net.py
python/paddle/v2/fluid/layers/nn.py Outdated
| | ||
| class SequenceDecoder: | ||
| class Cell: | ||
| modes = ('train', 'decode') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make modes be a enum variable.
python/paddle/v2/fluid/layers/nn.py Outdated
| class SequenceDecoder: | ||
| class Cell: | ||
| modes = ('train', 'decode') | ||
| kinds = ('step_input', 'state', 'other_shared') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think cell_types is a better name.
python/paddle/v2/fluid/layers/nn.py Outdated
| } | ||
| } | ||
| | ||
| def __init__(self, kind, id, init_var, dtype='float32'): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that id is a str variable, I think name is better.
python/paddle/v2/fluid/layers/nn.py Outdated
| class Cell: | ||
| modes = ('train', 'decode') | ||
| kinds = ('step_input', 'state', 'other_shared') | ||
| dic = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dic is not a good name, maybe holder?
python/paddle/v2/fluid/layers/nn.py Outdated
| if self.mode == 'train': | ||
| self.rnn = seqdec.train_rnn | ||
| | ||
| def create(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems create is not appropriate, consider to use a better name like switch_mode etc.
python/paddle/v2/fluid/layers/nn.py Outdated
| return item | ||
| return pd.array_read(array=item, i=counter) | ||
| | ||
| def _create_train(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_create_train --> _switch_to_train_mode
python/paddle/v2/fluid/layers/nn.py Outdated
| self.updater() | ||
| | ||
| @staticmethod | ||
| def get(mode, kind, id, counter=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get --> get_item ?
python/paddle/v2/fluid/layers/nn.py Outdated
| pd.array_write(selected_ids, array=ids_array, i=self.counter) | ||
| pd.array_write(selected_scores, array=scores_array, i=self.counter) | ||
| | ||
| for no, state in enumerate(self.states): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no --> state_idx
python/paddle/v2/fluid/layers/nn.py Outdated
| ''' | ||
| with self.train_rnn.block(): | ||
| # create item_id | ||
| self.item_id.set_mode('train') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
item_id is a str variable ? If so, please change a name.
… feature/add_beamsearch_interface
No description provided.