in python/mxboard/utils.py [0:0]
def _save_embedding_tsv(data, file_path):
"""Given a 2D `NDarray` or a `numpy.ndarray` as embeding,
save it in tensors.tsv under the path provided by the user."""
if isinstance(data, np.ndarray):
data_list = data.tolist()
elif isinstance(data, NDArray):
data_list = data.asnumpy().tolist()
else:
raise TypeError('expected NDArray of np.ndarray, while received type {}'.format(
str(type(data))))
with open(os.path.join(file_path, 'tensors.tsv'), 'w') as f:
for x in data_list:
x = [str(i) for i in x]
f.write('\t'.join(x) + '\n')