Skip to content

Commit

Permalink
Merge pull request #1121 from reyoung/feature/fix_ndarray_dtypes
Browse files Browse the repository at this point in the history
Fix bug in DenseScanner of DataProviderConverter.
  • Loading branch information
reyoung authored Jan 16, 2017
2 parents 0955977 + 2e47c9d commit c397e13
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions paddle/py_paddle/dataprovider_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ def finish_scan(self, argument):


class DenseScanner(IScanner):
"""
:type __mat__: numpy.ndarray
"""

def __init__(self, input_type, pos):
IScanner.__init__(self, input_type, pos)
self.__mat__ = None
Expand All @@ -47,6 +51,8 @@ def scan(self, dat):
def finish_scan(self, argument):
assert isinstance(argument, swig_paddle.Arguments)
assert isinstance(self.input_type, dp2.InputType)
if self.__mat__.dtype != numpy.float32:
self.__mat__ = self.__mat__.astype(numpy.float32)
m = swig_paddle.Matrix.createDenseFromNumpy(self.__mat__, True, False)
argument.setSlotValue(self.pos, m)

Expand Down

0 comments on commit c397e13

Please sign in to comment.