def __init__(self, space): self.space = space self.mask_space = SequenceMaskSpace() self.data_space = SequenceDataSpace(space) self.dim = space.get_total_dimension() super(SequenceSpace, self).__init__([self.data_space, self.mask_space]) self._dtype = self._clean_dtype_arg(space.dtype)
def _check_sizes(self, space): """ Called by self._format_as(space), to check whether self and space have compatible sizes. Throws a ValueError if they don't. """ my_dimension = self.get_total_dimension() other_dimension = space.get_total_dimension() if my_dimension != other_dimension: if isinstance(space, Conv2DSpace): if my_dimension * space.shape[0] !=\ other_dimension: raise ValueError( str(self) + " with total dimension " + str(my_dimension) + " can't format a batch into " + str(space) + "because its total dimension\ is " + str(other_dimension))
def _check_sizes(self, space): """ Called by self._format_as(space), to check whether self and space have compatible sizes. Throws a ValueError if they don't. """ my_dimension = self.get_total_dimension() other_dimension = space.get_total_dimension() if my_dimension != other_dimension: if isinstance(space, Conv2DSpace): if my_dimension * space.shape[0] !=\ other_dimension: raise ValueError(str(self)+" with total dimension " + str(my_dimension) + " can't format a batch into " + str(space) + "because its total dimension\ is " + str(other_dimension))
def __init__(self, space): self.dim = space.get_total_dimension() self.space = space self._dtype = self._clean_dtype_arg(space.dtype) super(SequenceDataSpace, self).__init__(space.dtype)