tfsnippet.preprocessing¶
-
class
tfsnippet.preprocessing.
BaseSampler
¶ Bases:
tfsnippet.dataflow.data_mappers.DataMapper
Base class for samplers.
-
_transform
(x)¶ Subclasses should override this to implement the transformation.
-
sample
(x)¶ Sample array according to x.
Parameters: x (np.ndarray) – The input x array. Returns: The sampled array. Return type: np.ndarray
-
-
class
tfsnippet.preprocessing.
BernoulliSampler
(dtype=<type 'numpy.int32'>, random_state=None)¶ Bases:
tfsnippet.preprocessing.samplers.BaseSampler
A
DataMapper
which can sample 0/1 integers according to the input probability. The input is assumed to be float numbers range within [0, 1) or [0, 1].-
__init__
(dtype=<type 'numpy.int32'>, random_state=None)¶ Construct a new
BernoulliSampler
.Parameters: - dtype – The data type of the sampled array. Default np.int32.
- random_state (RandomState) – Optional numpy RandomState for sampling.
(default
None
, use the globalRandomState
).
-
dtype
¶ Get the data type of the sampled array.
-
sample
(x)¶ Sample array according to x.
Parameters: x (np.ndarray) – The input x array. Returns: The sampled array. Return type: np.ndarray
-
-
class
tfsnippet.preprocessing.
UniformNoiseSampler
(minval=0.0, maxval=1.0, dtype=None, random_state=None)¶ Bases:
tfsnippet.preprocessing.samplers.BaseSampler
A
DataMapper
which can add uniform noise onto the input array. The data type of the returned array will be the same as the input array, unless dtype is specified at construction.-
__init__
(minval=0.0, maxval=1.0, dtype=None, random_state=None)¶ Construct a new
UniformNoiseSampler
.Parameters: - minval – The lower bound of the uniform noise (included).
- maxval – The upper bound of the uniform noise (excluded).
- dtype – The data type of the sampled array. Default np.int32.
- random_state (RandomState) – Optional numpy RandomState for sampling.
(default
None
, use the globalRandomState
).
-
dtype
¶ Get the data type of the sampled array.
-
maxval
¶ Get the upper bound of the uniform noise (excluded).
-
minval
¶ Get the lower bound of the uniform noise (included).
-
sample
(x)¶ Sample array according to x.
Parameters: x (np.ndarray) – The input x array. Returns: The sampled array. Return type: np.ndarray
-