Movatterモバイル変換


[0]ホーム

URL:


Skip to main content
Ctrl+K
JAX  documentation - Home

jax.numpy.save

Contents

jax.numpy.save#

jax.numpy.save(file,arr,allow_pickle=True,fix_imports=<novalue>)#

Save an array to a binary file in NumPy.npy format.

Parameters:
  • file (file,str, orpathlib.Path) – File or filename to which the data is saved. If file is a file-object,then the filename is unchanged. If file is a string or Path,a.npy extension will be appended to the filename if it does notalready have one.

  • arr (array_like) – Array data to be saved.

  • allow_pickle (bool,optional) – Allow saving object arrays using Python pickles. Reasons fordisallowing pickles include security (loading pickled data can executearbitrary code) and portability (pickled objects may not be loadableon different Python installations, for example if the stored objectsrequire libraries that are not available, and not all pickled data iscompatible between different versions of Python).Default: True

  • fix_imports (bool,optional) –

    Thefix_imports flag is deprecated and has no effect.

    Deprecated since version 2.1:This flag is ignored since NumPy 1.17 and was only needed tosupport loading in Python 2 some files written in Python 3.

See also

savez

Save several arrays into a.npz archive

savetxt,load

Notes

For a description of the.npy format, seenumpy.lib.format.

Any data saved to the file is appended to the end of the file.

Examples

>>>importnumpyasnp
>>>fromtempfileimportTemporaryFile>>>outfile=TemporaryFile()
>>>x=np.arange(10)>>>np.save(outfile,x)
>>>_=outfile.seek(0)# Only needed to simulate closing & reopening file>>>np.load(outfile)array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
>>>withopen('test.npy','wb')asf:...np.save(f,np.array([1,2]))...np.save(f,np.array([1,3]))>>>withopen('test.npy','rb')asf:...a=np.load(f)...b=np.load(f)>>>print(a,b)# [1 2] [1 3]
Contents

[8]ページ先頭

©2009-2025 Movatter.jp