如何将 NxNxN 数组(或矩阵)保存到 Julia(或 Python)中的文件中? [英] How to save an NxNxN array (or Matrix) into a file in Julia (or Python)?

查看:33
本文介绍了如何将 NxNxN 数组(或矩阵)保存到 Julia(或 Python)中的文件中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I'm working on a Jupyter notebook and currently using Julia

I'm trying to save a 3x3x3 Array into a textfile so when I include it in another notebook, the array is a 3x3x3 Array too.

Any suggestions? Thanks in advance.

解决方案

You could use the JLD.jl (Julia Data) package:

using Pkg
Pkg.add("JLD")
using JLD
r = rand(3, 3, 3)
save("data.jld", "data", r)
load("data.jld")["data"]

The advantage of the JLD package is that it preserves the exact type information of each variable.

这篇关于如何将 NxNxN 数组(或矩阵)保存到 Julia(或 Python)中的文件中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆