MCPcopy Index your code
hub / github.com/QData/TextAttack / transform

Function transform

examples/attack/attack_keras_parallel.py:57–65  ·  view source on GitHub ↗
(x)

Source from the content-addressed store, hash-verified

55
56
57def transform(x):
58 x_transform = []
59 for i, word_indices in enumerate(x):
60 BoW_array = np.zeros((NUM_WORDS,))
61 for index in word_indices:
62 if index < len(BoW_array):
63 BoW_array[index] += 1
64 x_transform.append(BoW_array)
65 return np.array(x_transform)
66
67
68class CustomKerasModelWrapper(ModelWrapper):

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected