gpt4 book ai didi

python - 如何将多个pickle文件放入一个pickle文件中

转载 作者:太空宇宙 更新时间:2023-11-03 21:18:59 29 4
gpt4 key购买 nike

我有两个 pickle 文件,其中包含 numpy ndarray 列表。

第一个泡菜文件:

{'encodings': [array([-0.18668848,  0.09167872,  0.02361359, -0.04610855, -0.11987427,
-0.06734911, 0.00542389, 0.02105863, 0.17828396, -0.00141097,
0.166828s45, -0.01075029, -0.20508201, 0.02762154, -0.00806585,
0.098497 , -0.17736666, -0.11334869, -0.10142692, -0.1134191 ,
0.06917755, 0.07989676, -0.04121129, 0.04280601, -0.12306173,
-0.29819348, -0.07650399, -0.10041754, 0.02334423, -0.06270325,
0.12638046, 0.10296188, -0.10587093, -0.08311734, 0.06213638,
0.08304631, -0.03443629, -0.08486824, 0.23685798, 0.01827276,
-0.10278646, 0.01152256, 0.08467054, 0.37257931, 0.15582474,
0.02709438, 0.04016857, -0.08466265, 0.14121686, -0.27717495,
0.13716345, 0.18896437, 0.05110805, 0.106585 , 0.15150583,
-0.1350172 , 0.02701535, 0.14240757, -0.17536291, 0.07862181,
0.06092819, 0.00497432, -0.03655054, -0.15420173, 0.1805391 ,
0.10382829, -0.07878115, -0.08832525, 0.15745324, -0.07997591,
-0.13981505, 0.04213319, -0.19279024, -0.15900737, -0.29393584,
0.10862678, 0.41602921, 0.15656555, -0.11855101, 0.04216752,
-0.0232455 , -0.03370954, 0.0355633 , 0.03816839, -0.13917619,
-0.06723036, -0.04189514, 0.11147611, 0.1995673 , 0.03261004,
-0.10638862, 0.1559474 , 0.05621403, -0.05708034, 0.0482568 ,
0.01418147, -0.04671318, -0.06601512, -0.20332824, -0.0691556 ,
0.12811929, -0.07675947, -0.01019647, 0.12645237, -0.19479996,
0.10532782, 0.03804317, -0.04418825, -0.06108642, 0.02885859,
-0.15403567, 0.05608891, 0.19509147, -0.15066354, 0.22698388,
0.12219262, 0.05469556, 0.15206271, 0.06922045, 0.04643065,
-0.02632714, -0.01712689, -0.09087028, -0.06960677, 0.08032852,
0.13741611, 0.06458308, 0.07958878])], 'names': ['tom']}

第二个泡菜文件:

{'encodings': [array([-1.10906549e-01,  2.82760076e-02,  1.40928570e-02, -7.55623430e-02,
-1.18420059e-02, -6.79435134e-02, 7.94159248e-04, -2.11588703e-02,
1.68759167e-01, -6.51913695e-03, 1.54918343e-01, 2.80910246e-02,
-2.08628818e-01, -2.71124691e-02, 2.27540880e-02, 3.07342559e-02,
-1.96070462e-01, -9.49537754e-02, -8.10625032e-02, -8.46448690e-02,
3.26108336e-02, 4.36929706e-03, 4.52538766e-02, 1.06669012e-02,
-1.42774120e-01, -3.27435136e-01, -9.54359397e-02, -1.95318609e-01,
6.05729260e-02, -7.79287443e-02, 6.29613698e-02, -1.52168227e-02,
-1.35686964e-01, -3.66957076e-02, 2.39675865e-04, 4.68941033e-02,
-4.50511239e-02, -3.71131971e-02, 1.89375550e-01, 4.80678454e-02,
-1.22665457e-01, -3.68929692e-02, -3.50655429e-03, 3.41097176e-01,
1.51335686e-01, 8.24191347e-02, 9.05722976e-02, -2.97215953e-03,
1.33755967e-01, -2.90517062e-01, 1.33845448e-01, 9.89130512e-02,
6.75613731e-02, 3.23878974e-02, 1.52221993e-01, -1.62803844e-01,
8.13175887e-02, 1.11765333e-01, -2.38216847e-01, 1.41546726e-01,
9.62506086e-02, 3.70164961e-03, -5.48346117e-02, 3.90823977e-03,
2.20120877e-01, 1.01806007e-01, -1.14795811e-01, -1.18746825e-01,
7.93062896e-02, -1.68676943e-01, -1.02184657e-02, 8.04015025e-02,
-1.35200977e-01, -1.91683397e-01, -2.35828787e-01, 1.02385968e-01,
4.50523496e-01, 1.27005681e-01, -7.58898705e-02, 4.50269431e-02,
-5.20654880e-02, -4.20882925e-02, 1.13409899e-01, 6.25026077e-02,
-1.17209882e-01, 2.94286814e-02, -1.15291528e-01, 5.63262142e-02,
1.39795944e-01, -1.62808914e-02, -4.35662456e-02, 1.33413598e-01,
-3.00255269e-02, -1.28360288e-02, -3.27749550e-03, 8.85868631e-03,
-1.23581521e-01, 4.58956361e-02, -5.75632229e-02, 6.86901249e-03,
1.01847328e-01, -7.13049620e-02, -4.22733976e-03, 5.29949181e-02,
-1.64895400e-01, 1.34815559e-01, -2.89627630e-02, -6.24453239e-02,
-3.33562531e-02, -2.41741575e-02, -9.46198851e-02, -3.14747319e-02,
1.33324310e-01, -2.73984402e-01, 1.59612253e-01, 2.19413936e-01,
4.25861105e-02, 1.33684829e-01, -2.11685020e-02, -3.15915793e-04,
1.95543766e-02, 8.47738683e-02, -1.88602582e-01, -2.10027974e-02,
-6.66024908e-03, 2.21308358e-02, -1.30187161e-03, -5.09036798e-03])], 'names': ['jack']}

我想要:

{'encodings': [array([-1.10906549e-01,  2.82760076e-02,  1.40928570e-02, -7.55623430e-02,
-1.18420059e-02, -6.79435134e-02, 7.94159248e-04, -2.11588703e-02,
1.68759167e-01, -6.51913695e-03, 1.54918343e-01, 2.80910246e-02,
-2.08628818e-01, -2.71124691e-02, 2.27540880e-02, 3.07342559e-02,
-1.96070462e-01, -9.49537754e-02, -8.10625032e-02, -8.46448690e-02,
3.26108336e-02, 4.36929706e-03, 4.52538766e-02, 1.06669012e-02,
-1.42774120e-01, -3.27435136e-01, -9.54359397e-02, -1.95318609e-01,
6.05729260e-02, -7.79287443e-02, 6.29613698e-02, -1.52168227e-02,
-1.35686964e-01, -3.66957076e-02, 2.39675865e-04, 4.68941033e-02,
-4.50511239e-02, -3.71131971e-02, 1.89375550e-01, 4.80678454e-02,
-1.22665457e-01, -3.68929692e-02, -3.50655429e-03, 3.41097176e-01,
1.51335686e-01, 8.24191347e-02, 9.05722976e-02, -2.97215953e-03,
1.33755967e-01, -2.90517062e-01, 1.33845448e-01, 9.89130512e-02,
6.75613731e-02, 3.23878974e-02, 1.52221993e-01, -1.62803844e-01,
8.13175887e-02, 1.11765333e-01, -2.38216847e-01, 1.41546726e-01,
9.62506086e-02, 3.70164961e-03, -5.48346117e-02, 3.90823977e-03,
2.20120877e-01, 1.01806007e-01, -1.14795811e-01, -1.18746825e-01,
7.93062896e-02, -1.68676943e-01, -1.02184657e-02, 8.04015025e-02,
-1.35200977e-01, -1.91683397e-01, -2.35828787e-01, 1.02385968e-01,
4.50523496e-01, 1.27005681e-01, -7.58898705e-02, 4.50269431e-02,
-5.20654880e-02, -4.20882925e-02, 1.13409899e-01, 6.25026077e-02,
-1.17209882e-01, 2.94286814e-02, -1.15291528e-01, 5.63262142e-02,
1.39795944e-01, -1.62808914e-02, -4.35662456e-02, 1.33413598e-01,
-3.00255269e-02, -1.28360288e-02, -3.27749550e-03, 8.85868631e-03,
-1.23581521e-01, 4.58956361e-02, -5.75632229e-02, 6.86901249e-03,
1.01847328e-01, -7.13049620e-02, -4.22733976e-03, 5.29949181e-02,
-1.64895400e-01, 1.34815559e-01, -2.89627630e-02, -6.24453239e-02,
-3.33562531e-02, -2.41741575e-02, -9.46198851e-02, -3.14747319e-02,
1.33324310e-01, -2.73984402e-01, 1.59612253e-01, 2.19413936e-01,
4.25861105e-02, 1.33684829e-01, -2.11685020e-02, -3.15915793e-04,
1.95543766e-02, 8.47738683e-02, -1.88602582e-01, -2.10027974e-02,
-6.66024908e-03, 2.21308358e-02, -1.30187161e-03, -5.09036798e-03]), array([-0.18668848, 0.09167872, 0.02361359, -0.04610855, -0.11987427,
-0.06734911, 0.00542389, 0.02105863, 0.17828396, -0.00141097,
0.16682845, -0.01075029, -0.20508201, 0.02762154, -0.00806585,
0.098497 , -0.17736666, -0.11334869, -0.10142692, -0.1134191 ,
0.06917755, 0.07989676, -0.04121129, 0.04280601, -0.12306173,
-0.29819348, -0.07650399, -0.10041754, 0.02334423, -0.06270325,
0.12638046, 0.10296188, -0.10587093, -0.08311734, 0.06213638,
0.08304631, -0.03443629, -0.08486824, 0.23685798, 0.01827276,
-0.10278646, 0.01152256, 0.08467054, 0.37257931, 0.15582474,
0.02709438, 0.04016857, -0.08466265, 0.14121686, -0.27717495,
0.13716345, 0.18896437, 0.05110805, 0.106585 , 0.15150583,
-0.1350172 , 0.02701535, 0.14240757, -0.17536291, 0.07862181,
0.06092819, 0.00497432, -0.03655054, -0.15420173, 0.1805391 ,
0.10382829, -0.07878115, -0.08832525, 0.15745324, -0.07997591,
-0.13981505, 0.04213319, -0.19279024, -0.15900737, -0.29393584,
0.10862678, 0.41602921, 0.15656555, -0.11855101, 0.04216752,
-0.0232455 , -0.03370954, 0.0355633 , 0.03816839, -0.13917619,
-0.06723036, -0.04189514, 0.11147611, 0.1995673 , 0.03261004,
-0.10638862, 0.1559474 , 0.05621403, -0.05708034, 0.0482568 ,
0.01418147, -0.04671318, -0.06601512, -0.20332824, -0.0691556 ,
0.12811929, -0.07675947, -0.01019647, 0.12645237, -0.19479996,
0.10532782, 0.03804317, -0.04418825, -0.06108642, 0.02885859,
-0.15403567, 0.05608891, 0.19509147, -0.15066354, 0.22698388,
0.12219262, 0.05469556, 0.15206271, 0.06922045, 0.04643065,
-0.02632714, -0.01712689, -0.09087028, -0.06960677, 0.08032852,
0.13741611, 0.06458308, 0.07958878])], 'names': ['jack', 'tom']}

如何将这两个 pickle 文件放入一个 pickle 文件中,以便“编码”位于一个位置,“名称”位于同一位置。每个编码都对应于最终 pickle 文件中的相应名称。

最佳答案

将第一个文件命名为 d1,将第二个文件命名为 d2,并使用下面的代码...让我知道这是否有帮助..否则我将再次编辑我的代码。

看看我尝试过什么可以建议你

d1={'encodings': [[-0.18668848,  0.09167872,  0.02361359, -0.04610855, -0.11987427,
-0.06734911, 0.00542389, 0.02105863, 0.17828396, -0.00141097,
0.16682845, -0.01075029, -0.20508201, 0.02762154, -0.00806585,
0.098497 , -0.17736666, -0.11334869, -0.10142692, -0.1134191 ,
0.06917755, 0.07989676, -0.04121129, 0.04280601, -0.12306173,
-0.29819348, -0.07650399, -0.10041754, 0.02334423, -0.06270325,
0.12638046, 0.10296188, -0.10587093, -0.08311734, 0.06213638,
0.08304631, -0.03443629, -0.08486824, 0.23685798, 0.01827276,
-0.10278646, 0.01152256, 0.08467054, 0.37257931, 0.15582474,
0.02709438, 0.04016857, -0.08466265, 0.14121686, -0.27717495,
0.13716345, 0.18896437, 0.05110805, 0.106585 , 0.15150583,
-0.1350172 , 0.02701535, 0.14240757, -0.17536291, 0.07862181,
0.06092819, 0.00497432, -0.03655054, -0.15420173, 0.1805391 ,
0.10382829, -0.07878115, -0.08832525, 0.15745324, -0.07997591,
-0.13981505, 0.04213319, -0.19279024, -0.15900737, -0.29393584,
0.10862678, 0.41602921, 0.15656555, -0.11855101, 0.04216752,
-0.0232455 , -0.03370954, 0.0355633 , 0.03816839, -0.13917619,
-0.06723036, -0.04189514, 0.11147611, 0.1995673 , 0.03261004,
-0.10638862, 0.1559474 , 0.05621403, -0.05708034, 0.0482568 ,
0.01418147, -0.04671318, -0.06601512, -0.20332824, -0.0691556 ,
0.12811929, -0.07675947, -0.01019647, 0.12645237, -0.19479996,
0.10532782, 0.03804317, -0.04418825, -0.06108642, 0.02885859,
-0.15403567, 0.05608891, 0.19509147, -0.15066354, 0.22698388,
0.12219262, 0.05469556, 0.15206271, 0.06922045, 0.04643065,
-0.02632714, -0.01712689, -0.09087028, -0.06960677, 0.08032852,
0.13741611, 0.06458308, 0.07958878]], 'names': ['tom']}
d2={'encodings': [[-1.10906549e-01, 2.82760076e-02, 1.40928570e-02, -7.55623430e-02,
-1.18420059e-02, -6.79435134e-02, 7.94159248e-04, -2.11588703e-02,
1.68759167e-01, -6.51913695e-03, 1.54918343e-01, 2.80910246e-02,
-2.08628818e-01, -2.71124691e-02, 2.27540880e-02, 3.07342559e-02,
-1.96070462e-01, -9.49537754e-02, -8.10625032e-02, -8.46448690e-02,
3.26108336e-02, 4.36929706e-03, 4.52538766e-02, 1.06669012e-02,
-1.42774120e-01, -3.27435136e-01, -9.54359397e-02, -1.95318609e-01,
6.05729260e-02, -7.79287443e-02, 6.29613698e-02, -1.52168227e-02,
-1.35686964e-01, -3.66957076e-02, 2.39675865e-04, 4.68941033e-02,
-4.50511239e-02, -3.71131971e-02, 1.89375550e-01, 4.80678454e-02,
-1.22665457e-01, -3.68929692e-02, -3.50655429e-03, 3.41097176e-01,
1.51335686e-01, 8.24191347e-02, 9.05722976e-02, -2.97215953e-03,
1.33755967e-01, -2.90517062e-01, 1.33845448e-01, 9.89130512e-02,
6.75613731e-02, 3.23878974e-02, 1.52221993e-01, -1.62803844e-01,
8.13175887e-02, 1.11765333e-01, -2.38216847e-01, 1.41546726e-01,
9.62506086e-02, 3.70164961e-03, -5.48346117e-02, 3.90823977e-03,
2.20120877e-01, 1.01806007e-01, -1.14795811e-01, -1.18746825e-01,
7.93062896e-02, -1.68676943e-01, -1.02184657e-02, 8.04015025e-02,
-1.35200977e-01, -1.91683397e-01, -2.35828787e-01, 1.02385968e-01,
4.50523496e-01, 1.27005681e-01, -7.58898705e-02, 4.50269431e-02,
-5.20654880e-02, -4.20882925e-02, 1.13409899e-01, 6.25026077e-02,
-1.17209882e-01, 2.94286814e-02, -1.15291528e-01, 5.63262142e-02,
1.39795944e-01, -1.62808914e-02, -4.35662456e-02, 1.33413598e-01,
-3.00255269e-02, -1.28360288e-02, -3.27749550e-03, 8.85868631e-03,
-1.23581521e-01, 4.58956361e-02, -5.75632229e-02, 6.86901249e-03,
1.01847328e-01, -7.13049620e-02, -4.22733976e-03, 5.29949181e-02,
-1.64895400e-01, 1.34815559e-01, -2.89627630e-02, -6.24453239e-02,
-3.33562531e-02, -2.41741575e-02, -9.46198851e-02, -3.14747319e-02,
1.33324310e-01, -2.73984402e-01, 1.59612253e-01, 2.19413936e-01,
4.25861105e-02, 1.33684829e-01, -2.11685020e-02, -3.15915793e-04,
1.95543766e-02, 8.47738683e-02, -1.88602582e-01, -2.10027974e-02,
-6.66024908e-03, 2.21308358e-02, -1.30187161e-03, -5.09036798e-03]], 'names': ['jack']}
d3={key: value + d2[key] for key, value in d1.iteritems()}
d3

关于python - 如何将多个pickle文件放入一个pickle文件中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54454592/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com