in sagemaker/src/utils.py [0:0]
def decode(prediction):
'''
Returns the string given one-hot encoded vectors.
'''
alphabet_encoding = r'0123456789abcdefghijklmnopqrstuvwxyz'
alphabet_dict = {alphabet_encoding[i]:i for i in range(len(alphabet_encoding))}
results = []
for word in prediction:
result = []
for i, index in enumerate(word):
if i < len(word) - 1 and word[i] == word[i+1] and word[-1] != -1: #Hack to decode label as well
continue
if index == len(alphabet_dict) or index == -1:
continue
else:
result.append(alphabet_encoding[int(index)])
results.append(result)
words = [''.join(word) for word in results]
return words