Merged
Conversation
A v2 API like data feeder for book demos. We can feed data directly from reader.
QiJune
reviewed
Dec 1, 2017
|
|
||
|
|
||
| class DataToLoDTensorConverter(object): | ||
| def __init__(self, place, lod_level, shape, batch_size_dim, dtype): |
Member
There was a problem hiding this comment.
It seems that batch_size_dim here is no use.
Collaborator
Author
There was a problem hiding this comment.
Yes. batch_size_dim could be removed.
| elif dtype == core.DataType.FP64: | ||
| self.dtype = 'float64' | ||
| elif dtype == core.DataType.INT32: | ||
| self.dtype = 'int32' |
| arr = numpy.array(self.data, dtype=self.dtype).reshape(self.shape) | ||
| t = core.LoDTensor() | ||
| t.set(arr, self.place) | ||
| if self.lod_level != 0: |
| self.feed_names.append(each_var.name) | ||
| shape = each_var.shape | ||
| batch_size_dim = -1 | ||
| for i, s in enumerate(shape): |
Member
There was a problem hiding this comment.
Is not batch_size_dim always in the first dimension?
Collaborator
Author
There was a problem hiding this comment.
No, batch_size_dim is not the first dimension if we use static RNN
| converter = [] | ||
| for lod_level, shape, dtype in six.zip( | ||
| self.feed_lod_level, self.feed_shapes, self.feed_dtypes): | ||
| batch_size_dim, shape = shape |
Member
There was a problem hiding this comment.
This line take batch_size_dim as the first dimension.
Collaborator
Author
There was a problem hiding this comment.
No. shape is a tuple before.
Also add __all__ to data_feeder.py
6508c83 to
2d520eb
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A v2 API like data feeder for book demos.
We can feed data directly from reader.
Fix #6101