Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _pad(self, side, length):
"""
Pad sequences to given length in the left or right side.
"""
if self._train_set:
self._train_set = pad_dataset(self._train_set, side, length)
if self._valid_set:
self._valid_set = pad_dataset(self._valid_set, side, length)
if self._test_set:
self._test_set = pad_dataset(self._test_set, side, length)
def _pad(self, side, length):
"""
Pad sequences to given length in the left or right side.
"""
if self._train_set:
self._train_set = pad_dataset(self._train_set, side, length)
if self._valid_set:
self._valid_set = pad_dataset(self._valid_set, side, length)
if self._test_set:
self._test_set = pad_dataset(self._test_set, side, length)
def _pad(self, side, length):
"""
Pad sequences to given length in the left or right side.
"""
if self._train_set:
self._train_set = pad_dataset(self._train_set, side, length)
if self._valid_set:
self._valid_set = pad_dataset(self._valid_set, side, length)
if self._test_set:
self._test_set = pad_dataset(self._test_set, side, length)
def _yield_data(self, subset):
for i in xrange(0, len(subset), self.size):
x_set, y_set = [], []
batch = pad_dataset(subset[i:i + self.size], PADDING_SIDE, self.padding_length)
for x, y in batch:
x_set.append(x)
y_set.append(y)
x_set = np.array(x_set)
y_set = np.array(y_set)
if self._fix_batch_size and x_set.shape[0] != self.size:
continue
yield x_set, y_set