0

I defined a function which returns embeddings of n dimensions for a list of strings.

The tensorflow embeddings which is a tensor are accessed by

(tensor_embeddings).numpy().tolist[0]

I would like to understand this way of accessing the embeddings and if below code does the same job

numpy.array(embeddings).tolist[0]
Kaveh
  • 4,618
  • 2
  • 20
  • 33
  • Yes. It's exactly the same in results. The first one is implemented by tensorflow, and the second one is implemented by numpy. The first one is not available when you are using tensorflow 1 with eager execution disabled. – Kaveh Jun 22 '21 at 19:43
  • Just sharing this link here, in case you hadn't seen it: https://stackoverflow.com/questions/34097281/convert-a-tensor-to-numpy-array-in-tensorflow – sbecon Jun 22 '21 at 19:43

1 Answers1

0

(tensor_embeddings).numpy().tolist[0] and numpy.array(embeddings).tolist[0]:

They are exactly the same in results.

The first one is implemented by tensorflow library, and the second one is implemented by numpy library.

The first one is not available when you are using tensorflow 1 with eager execution disabled. In tensorflow 2 eager execution is enabled by default.

Kaveh
  • 4,618
  • 2
  • 20
  • 33