0

How to save tensorflow specific variable to local disk as a ndarray?(not layer parameter,just a variable, or tensor) Like :

ux=tf.Variable([10,1600,1,2])

tf.save('ux.npy',ux)

Is there anything like the code above? And after that I can load the ux.npy like:

ux = numpy.load('ux.npy')
numberjcc
  • 21
  • 4
  • [this](https://stackoverflow.com/questions/33679382/tensorflow-get-current-value-of-a-variable) and then you can save the numpy array that you get from it – jpm May 31 '17 at 23:32

1 Answers1

0

Numpy has save and load function itself so for saving the numpy array you can use its function. The syntax is:

numpy.savetxt(Out_file_name, numpy_to_save)
ida
  • 1,011
  • 1
  • 9
  • 17
  • why this error : >>> import tensorflow as tf >>> import numpy as np >>> ux=tf.Variable([10,1600,1,2]) >>> np.savetxt('ux.npy',ux) Traceback (most recent call last): File "", line 1, in File "/home/jcc/anaconda2/lib/python2.7/site-packages/numpy/lib/npyio.py", line 1118, in savetxt ncol = X.shape[1] IndexError: tuple index out of range >>> – numberjcc Apr 02 '17 at 14:12
  • can you try save instead of savetxt? – ida Apr 02 '17 at 15:54