如下所示是一个 二重字典
a={'d2': {0: array([[ 0.00871335, -0.00310053, 0.00816491, ..., 0.00694641,
0.00464299, 0.01580841],
[ 0.00882073, -0.00029377, -0.00521681, ..., 0.0017954 ,
-0.00096381, 0.00824287],
[-0.01408937, -0.01837206, -0.00485921, ..., -0.01511015,
0.00807125, 0.00533095],
...,
[-0.00698953, -0.01096657, -0.00069139, ..., 0.0074601 ,
-0.00884891, -0.01019121],
[ 0.00859948, -0.01566835, -0.00434298, ..., -0.00238856,
-0.0130352 , -0.00683055],
[-0.01509122, -0.00864898, -0.00224272, ..., 0.00510187,
0.02850735, 0.01109586]], dtype=float32), 1: array([0.0061985 , 0.00894898, 0.00745794, ..., 0.00713845, 0.00400312,
0.00647078], dtype=float32)}, 'd0': {0: array([[-9.36617050e-03, 1.91615261e-02, -2.63120234e-03, ...,
-2.54409444e-02, -1.52641935e-02, -3.81520507e-03],
[ 2.81851669e-03, -4.47405595e-03, -3.64252657e-04, ...,
5.27272327e-03, 1.60645843e-02, 3.04719526e-02],
[ 1.35175772e-02, -1.58857647e-02, 5.16392197e-03, ...,
2.37502549e-02, 5.49422540e-02, 1.75002008e-03],
...,
[-3.70402052e-03, 8.81176256e-03, -4.84202523e-03, ...,
-2.73294834e-04, -1.19641300e-06, -8.35334230e-03],
[-8.44872557e-03, 1.09267384e-02, 1.51051942e-03, ...,
8.99275951e-03, -1.54636300e-03, -4.24145861e-03],
[ 8.79182573e-03, 2.45544617e-03, -1.23095885e-02, ...,
1.59229040e-02, -2.14620100e-04, -5.90445800e-03]], dtype=float32), 1: array([-0.00353968, -0.00191601, -0.0031053 , ..., -0.00241514,
-0.00092808, -0.00046262], dtype=float32)}, 'd1': {0: array([[-1.6329676e-02, -1.3014785e-02, -4.6453285e-03, ...,
3.5180598e-03, 2.0823872e-02, 3.7640433e-03],
[ 3.6907033e-03, -2.6941486e-02, -1.1666526e-02, ...,
-1.4129423e-02, -2.6815615e-03, -1.6096963e-02],
[ 3.9101271e-03, -2.0824514e-02, -1.0803237e-02, ...,
1.6408941e-02, 1.1522076e-02, -1.9077018e-03],
...,
[-5.0139022e-03, -1.0959036e-02, 3.1243467e-03, ...,
-1.6651856e-02, 1.1660077e-03, -2.1639844e-02],
[ 1.4273456e-02, -1.8649664e-02, -8.8115009e-03, ...,
-9.7126309e-03, 3.5502622e-03, -9.1997543e-03],
[ 2.4932554e-02, 3.1009965e-02, 5.3369935e-04, ...,
6.4374130e-05, -1.7689992e-02, -5.9350333e-03]], dtype=float32), 1: array([-0.0061101 , -0.00553799, -0.0039381 , ..., -0.00618161,
-0.00552918, -0.00613742], dtype=float32)}}
保存:
import numpy as np
np.save('a.npy', a)
读入:
a=np.load('a.npy')
data=a.item()
至此,data即为读出的字典