Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions textattack/datasets/huggingface_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def __init__(

self.shuffled = shuffle
if shuffle:
self._dataset.shuffle()
self._dataset = self._dataset.shuffle()

def _format_as_dict(self, example):
input_dict = collections.OrderedDict(
Expand Down Expand Up @@ -190,5 +190,5 @@ def __getitem__(self, i):
]

def shuffle(self):
self._dataset.shuffle()
self._dataset = self._dataset.shuffle()
self.shuffled = True
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def _alter_number(self, num):
"""Helper function of _get_new_number, replace a number with another
random number within the range of self.max_change."""
if num not in [0, 2, 4]:
change = int(num * self.max_change) + 1
change = abs(int(num * self.max_change)) + 1
if num >= 0:
num_list = np.random.randint(max(num - change, 1), num + change, self.n)
else:
Expand Down
Loading