Commit 843ab15c authored by Yuxin Wu's avatar Yuxin Wu

update docs

parent f87b431b
...@@ -22,8 +22,8 @@ class FakeData(RNGDataFlow): ...@@ -22,8 +22,8 @@ class FakeData(RNGDataFlow):
size (int): size of this DataFlow. size (int): size of this DataFlow.
random (bool): whether to randomly generate data every iteration. random (bool): whether to randomly generate data every iteration.
Note that merely generating the data could sometimes be time-consuming! Note that merely generating the data could sometimes be time-consuming!
dtype (str): data type as string or a list of data types. dtype (str or list): data type as string, or a list of data types.
domain (str): domain of values as tuple/list. domain (tuple or list): (min, max) tuple, or a list of such tuples
""" """
super(FakeData, self).__init__() super(FakeData, self).__init__()
self.shapes = shapes self.shapes = shapes
...@@ -31,6 +31,8 @@ class FakeData(RNGDataFlow): ...@@ -31,6 +31,8 @@ class FakeData(RNGDataFlow):
self.random = random self.random = random
self.dtype = [dtype] * len(shapes) if isinstance(dtype, six.string_types) else dtype self.dtype = [dtype] * len(shapes) if isinstance(dtype, six.string_types) else dtype
self.domain = [domain] * len(shapes) if isinstance(domain, tuple) else domain self.domain = [domain] * len(shapes) if isinstance(domain, tuple) else domain
assert len(self.dtype) == len(self.shapes)
assert len(self.domain) == len(self.domain)
def size(self): def size(self):
return self._size return self._size
...@@ -49,7 +51,7 @@ class FakeData(RNGDataFlow): ...@@ -49,7 +51,7 @@ class FakeData(RNGDataFlow):
v = self.rng.rand(*self.shapes[k]) * (self.domain[k][1] - self.domain[k][0]) + self.domain[k][0] v = self.rng.rand(*self.shapes[k]) * (self.domain[k][1] - self.domain[k][0]) + self.domain[k][0]
val.append(v.astype(self.dtype[k])) val.append(v.astype(self.dtype[k]))
for _ in range(self._size): for _ in range(self._size):
yield copy.deepcopy(val) yield copy.copy(val)
class DataFromQueue(DataFlow): class DataFromQueue(DataFlow):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment