def truncate_data(perc, dataset):
  """Truncate the training dataset.

  Args:
    perc: float between 0 and 1, percentage of data kept.
    dataset: data, under the form (x_train, y_train), (x_test, y_test)
  Returns:
    dataset: truncated training dataset, full test dataset
  """
  (x_train, y_train), (x_test, y_test) = dataset
  n = x_train.shape[0]
  n_trunc = int(perc * n)
  return (x_train[:n_trunc, :], y_train[:n_trunc, :]), (x_test, y_test)