如果您想了解将大数据集从列表转换为numpy数组时出现numpy内存错误和数据集转化为npy文件的知识,那么本篇文章将是您的不二之选。我们将深入剖析将大数据集从列表转换为numpy数组时出现numpy
如果您想了解将大数据集从列表转换为 numpy 数组时出现 numpy 内存错误和数据集转化为npy文件的知识,那么本篇文章将是您的不二之选。我们将深入剖析将大数据集从列表转换为 numpy 数组时出现 numpy 内存错误的各个方面,并为您解答数据集转化为npy文件的疑在这篇文章中,我们将为您介绍将大数据集从列表转换为 numpy 数组时出现 numpy 内存错误的相关知识,同时也会详细的解释数据集转化为npy文件的运用方法,并给出实际的案例分析,希望能帮助到您!
本文目录一览:- 将大数据集从列表转换为 numpy 数组时出现 numpy 内存错误(数据集转化为npy文件)
- "import numpy as np" ImportError: No module named numpy
- 16MB 版本上的 Micropython ESP32 内存错误
- 37 字节文件的pickle 内存错误
- Angular 10 run ng服务获取webpack,内存错误
将大数据集从列表转换为 numpy 数组时出现 numpy 内存错误(数据集转化为npy文件)
如何解决将大数据集从列表转换为 numpy 数组时出现 numpy 内存错误
我正在为神经网络训练预处理一个大型数据集。我的数据集累积在 features = list()
。
尝试 features = np.array(features)
时,我得到:
numpy.core._exceptions.MemoryError: 无法为形状为 (37990,605,173) 且数据类型为 float64 的数组分配 29.6 GiB
我在其他帖子中看到了许多解决方案,例如 saving and reloading,由于 np.save
首先转换为数组,或者 using uint8 用于图像,或者更低尽可能格式化内存。
问题是,我的输入是张量机器人,而不是图像。我不确定最大值是多少,并且由于我的分类任务,我不知道是否可以使用其他格式。由于实现开销,我试图避免使用 keras 生成器。所以,我的问题是,有没有办法在不使用生成器的情况下处理这个数据集?
解决方法
您可以使用 numpy 的 mmap() 支持:这将通过磁盘上的文件支持数据,同时仍然像普通的 numpy 数组一样工作。所以它不必适合内存。
https://numpy.org/doc/stable/reference/generated/numpy.memmap.html
请参阅 https://pythonspeed.com/articles/mmap-vs-zarr-hdf5/ 以了解其工作原理。
"import numpy as np" ImportError: No module named numpy
问题:没有安装 numpy
解决方法:
下载文件,安装
numpy-1.8.2-win32-superpack-python2.7
安装运行 import numpy,出现
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
import numpy
File "C:\Python27\lib\site-packages\numpy\__init__.py", line 153, in <module>
from . import add_newdocs
File "C:\Python27\lib\site-packages\numpy\add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "C:\Python27\lib\site-packages\numpy\lib\__init__.py", line 8, in <module>
from .type_check import *
File "C:\Python27\lib\site-packages\numpy\lib\type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "C:\Python27\lib\site-packages\numpy\core\__init__.py", line 6, in <module>
from . import multiarray
ImportError: DLL load failed: %1 不是有效的 Win32 应用程序。
原因是:python 装的是 64 位的,numpy 装的是 32 位的
重新安装 numpy 为:numpy-1.8.0-win64-py2.7
16MB 版本上的 Micropython ESP32 内存错误
如何解决16MB 版本上的 Micropython ESP32 内存错误
我有以下问题:
">OKMemoryError: 内存分配失败,正在分配 13759 字节"
我尝试过 ESP32 4MB 和 16MB 闪存,所以没有办法,它无法处理此代码。 我相信这是因为“零”、“一个”、“两个”变量,因为当我将它们注释掉并只保留“零”时,例如,它工作正常。但是..我的意思是来吧,整个文件是38kb,ESP32的内存是16MB,它必须处理它......
有什么问题?
from machine import Pin,I2C
import ssd1306
from time import sleep
# ESP32 Pin assignment
i2c = I2C(-1,scl=Pin(22),sda=Pin(21))
i2c2 = I2C(-1,scl=Pin(4),sda=Pin(2))
i2c3 = I2C(-1,scl=Pin(19),sda=Pin(18))
i2c4 = I2C(-1,scl=Pin(5),sda=Pin(15))
i2c5 = I2C(-1,scl=Pin(32),sda=Pin(33))
ZERO = [[0,1,0],[0,0]]
ONE = [[0,0]]
TWO = [[0,0]]
oled_width = 128
oled_height = 64
oled = ssd1306.SSD1306_I2C(oled_width,oled_height,i2c)
oled2 = ssd1306.SSD1306_I2C(oled_width,i2c2)
oled3 = ssd1306.SSD1306_I2C(oled_width,i2c3)
oled4 = ssd1306.SSD1306_I2C(oled_width,i2c4)
oled5 = ssd1306.SSD1306_I2C(oled_width,i2c5)
oled.fill(0) # Clear the display
for y,row in enumerate(ZERO):
for x,c in enumerate(row):
oled.pixel(x + 0,y,c)
oled.show()
oled2.fill(0) # Clear the display
for y,c in enumerate(row):
oled2.pixel(x + 0,c)
oled2.show()
oled3.fill(0) # Clear the display
for y,c in enumerate(row):
oled3.pixel(x + 0,c)
oled3.show()
oled4.fill(0) # Clear the display
for y,c in enumerate(row):
oled4.pixel(x + 0,c)
oled4.show()
oled5.fill(0) # Clear the display
for y,c in enumerate(row):
oled5.pixel(x + 0,c)
oled5.show()
解决方法
您的程序内存不足。 ESP32 有 520 KiB 的 RAM,其中 328 KiB 用于数据,192 KiB 用于指令。这必须适合 Python 解释器(它本身就是一个需要大量内存的程序)以及您的脚本使用的所有内容。
在这里,您创建了 3 个巨大的 32 位整数数组,它们共同分配了整个数据 RAM 的 30%(每个需要 128x64x4=32KiB 来存储仅 1KiB 的帧数据)。事情不是这样完成的。此外,我不知道您正在创建的 5 个 SSD1306 驱动程序内部是什么 - 也许是它们自己的帧缓冲区?
如果您确定这是要走的路,请获取 ESP-WROVER-B 模块,该模块添加了 8 MiB 的 PSRAM。
37 字节文件的pickle 内存错误
如何解决37 字节文件的pickle 内存错误
示例代码:
pfile=open("main.txt","rb")
size=os.stat("main.txt")
print(size.st_size)
records=pickle.load(pfile)
pfile.close()
我试图运行这段代码,但它最终给出了一个内存错误, 文件大小仅为 37 字节。
在以二进制模式创建文件后,我手动对其进行了一些更改,之后此错误开始出现。
错误窗口:
37
Traceback (most recent call last):
File "D:\\Programming\\apne py pr\\startn games\\spac inv startn.py",line 693,in <module>
chkpwd()
File "D:\\Programming\\apne py pr\\startn games\\spac inv startn.py",line 631,in chkpwd
records=pickle.load(pfile)
MemoryError
请解释为什么会这样。
编辑 1:整个代码块。
def chkpwd():
global password
try:
pfile=open("main.txt","rb")
size=os.stat("main.txt")
print(size.st_size)
pickletools.dis(pfile)
records=pickle.load(pfile)
pfile.close()
if len(records)>0:
password=records[0]
try:
con=msc.connect(user="root",host="localhost",passwd=password)
con.close()
__main__()
except:
os.remove("main.txt")
chkpwd()
except (FileNotFoundError,EOFError):
pfile=open("main.txt","wb")
def lenchk():
global password
if len(tp.get())>0:
z.append(tp.get())
password=tp.get()
pickle.dump([password],pfile)
pfile.close()
pcont.destroy()
else:
pcont.destroy()
messageBox.showinfo("","Enter your MysqL Password")
chkpwd()
z=[]
pcont=Tk()
pcont.geometry("450x240+300+300")
pcont.config(bg="#bdffdb")
pcont.overrideredirect(True)
lp=Label(pcont,text="Enter PASSWORD of your \\nMysqL Server",bg="#bdffdb",fg="black",font="courier 23 bold")
bp=Button(pcont,width=3,text="OK",pady=-1,command=lenchk,bg=''white'',font="courier 22 bold",bd=4)
tp=Entry(pcont,width=14,bd=4,show="*")
close_it(pcont)
lp.place(x=15,y=54)
tp.place(x=40,y=157)
bp.place(x=330,y=146)
pcont.mainloop()
if len(z)>0:
try:
con=msc.connect(user="root",passwd=password)
cur=con.cursor()
q="create database if not exists inv"
cur.execute(q)
con.commit()
q="use inv"
cur.execute(q)
con.commit()
q="create table if not exists invaders(name varchar(15) primary key,lv_1 int,lv_2 int)"
cur.execute(q)
con.commit()
con.close()
__main__()
except :
messageBox.showerror(""," Wrong Password ")
os.remove("main.txt")
chkpwd()
else:
pfile.close()
os.remove("main.txt")
编辑2:通过pickletools.dis()
37
0: \\x80 PROTO 4
2: \\x95 FRAME 2314885530818453519
Traceback (most recent call last):
File "D:\\Programming\\apne py pr\\startn games\\spac inv startn.py",line 695,line 632,in chkpwd
pickletools.dis(pfile)
File "C:\\Users\\Anush\\AppData\\Local\\Programs\\Python\\python39\\lib\\pickletools.py",line 2448,in dis
for opcode,arg,pos in genops(pickle):
File "C:\\Users\\Anush\\AppData\\Local\\Programs\\Python\\python39\\lib\\pickletools.py",line 2285,in _genops
raise ValueError("at position %s,opcode %r unkNown" % (
ValueError: at position 11,opcode b'' '' unkNown
Angular 10 run ng服务获取webpack,内存错误
如何解决Angular 10 run ng服务获取webpack,内存错误
我只是尝试在MacOS机器上创建Angular应用程序。
5 != -1
我为此项目使用了 npm install -g @angular/cli ng new my-app cd my-app ng serve
(尽管我在全球共有14个)
nvm use 12
package.json文件
_ _ ____ _ ___
/ \\ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \\ | ''_ \\ / _` | | | | |/ _` | ''__| | | | | | |
/ ___ \\| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \\_\\_| |_|\\__,|\\__,_|_|\\__,_|_| \\____|_____|___|
|___/
Angular CLI: 10.1.4
Node: 12.16.3
OS: darwin x64
Angular:
...
Ivy Workspace:
Package Version
------------------------------------------------------
@angular-devkit/architect 0.1001.4
@angular-devkit/core 10.1.4
@angular-devkit/schematics 10.1.4
@schematics/angular 10.1.4
@schematics/update 0.1001.4
当我执行{ "sideEffects": false,"name": "ng-satire-site","version": "0.0.0","scripts": { "ng": "ng","start": "ng serve","build": "ng build","test": "ng test","lint": "ng lint","e2e": "ng e2e" },"private": true,"dependencies": { "@angular/animations": "~10.1.4","@angular/common": "~10.1.4","@angular/compiler": "~10.1.4","@angular/core": "~10.1.4","@angular/forms": "~10.1.4","@angular/platform-browser": "~10.1.4","@angular/platform-browser-dynamic": "~10.1.4","@angular/router": "~10.1.4","rxjs": "~6.6.0","tslib": "^2.0.0","zone.js": "~0.10.2" },"devDependencies": { "@angular-devkit/build-angular": "^0.1001.4","@angular/cli": "~10.1.4","@angular/compiler-cli": "~10.1.4","@types/jasmine": "~3.5.0","@types/jasminewd2": "~2.0.3","@types/node": "^12.11.1","codelyzer": "^6.0.0","jasmine-core": "~3.6.0","jasmine-spec-reporter": "~5.0.0","karma": "~5.0.0","karma-chrome-launcher": "~3.1.0","karma-coverage-istanbul-reporter": "~3.0.2","karma-jasmine": "~4.0.0","karma-jasmine-html-reporter": "^1.5.0","protractor": "~7.0.0","ts-node": "~8.3.0","tslint": "~6.1.0","typescript": "~4.0.2" } }
时,localhost:4200将挂起,直到1分钟后由于以下错误而失败
ng serve
我曾尝试从github克隆一个现有存储库,但与此设备和我的工作计算机存在相同的问题。当MacOS无法克隆相同的存储库时,工作计算机可以正常工作。我曾尝试在此设备上克隆其他角度应用程序,但最初遇到此错误
92% additional asset processing copy-webpack-plugin
<--- Last few GCs --->
[22997:0x102a7f000] 79239 ms: Mark-sweep 2031.0 (2063.4) -> 2027.7 (2063.9) MB,1974.0 / 3.2 ms (average mu = 0.135,current mu = 0.015) allocation failure scavenge might not succeed
[22997:0x102a7f000] 80618 ms: Mark-sweep 2033.6 (2063.9) -> 2027.6 (2081.7) MB,1360.3 / 3.4 ms (average mu = 0.084,current mu = 0.013) allocation failure scavenge might not succeed
<--- JS stacktrace --->
==== JS stack trace =========================================
0: ExitFrame [pc: 0x10097cc39]
1: StubFrame [pc: 0x10097dcd3]
Security context: 0x2d29bc4408d1 <JSObject>
2: normalize [0x2d29ac580511] [path.js:~1004] [pc=0x26c80fc5e45b](this=0x2d291c73fe89 <Object map = 0x2d29a4a2f7d9>,0x2d2931037269 <String[70]: /Users/da/Downloads/CIVIL WAR GENERALS 2/CWG2/CWG2/SCENARIO/WINC2H.MLB>)
3: /* anonymous */ [0x2d293e871039] [/Users/da/*code*/ng-tests/ng-satire-app/node_modules/chokidar/lib/...
Fatal error: Ineffective mark-compacts near heap limit Allocation Failed - JavaScript heap out of memory
Writing Node.js report to file: report.20201002.111236.22997.0.001.json
Node.js report completed
1: 0x1010285f9 node::Abort() (.cold.1) [/Users/da/.nvm/versions/node/v12.16.3/bin/node]
2: 0x10008634d node::FatalError(char const*,char const*) [/Users/da/.nvm/versions/node/v12.16.3/bin/node]
3: 0x10008648e node::OnFatalError(char const*,char const*) [/Users/da/.nvm/versions/node/v12.16.3/bin/node]
4: 0x100187c07 v8::Utils::ReportOOMFailure(v8::internal::Isolate*,char const*,bool) [/Users/da/.nvm/versions/node/v12.16.3/bin/node]
5: 0x100187ba7 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*,bool) [/Users/da/.nvm/versions/node/v12.16.3/bin/node]
6: 0x100315955 v8::internal::Heap::FatalProcessOutOfMemory(char const*) [/Users/da/.nvm/versions/node/v12.16.3/bin/node]
7: 0x1003171ca v8::internal::Heap::RecomputeLimits(v8::internal::GarbageCollector) [/Users/da/.nvm/versions/node/v12.16.3/bin/node]
8: 0x100313bfc v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector,v8::GCCallbackFlags) [/Users/da/.nvm/versions/node/v12.16.3/bin/node]
9: 0x1003119fe v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace,v8::internal::GarbageCollectionReason,v8::GCCallbackFlags) [/Users/da/.nvm/versions/node/v12.16.3/bin/node]
10: 0x10031d8ca v8::internal::Heap::AllocaterawWithLightRetry(int,v8::internal::AllocationType,v8::internal::Allocationorigin,v8::internal::AllocationAlignment) [/Users/da/.nvm/versions/node/v12.16.3/bin/node]
11: 0x10031d951 v8::internal::Heap::AllocaterawWithRetryOrFail(int,v8::internal::AllocationAlignment) [/Users/da/.nvm/versions/node/v12.16.3/bin/node]
12: 0x1002eb58a v8::internal::Factory::NewFillerObject(int,bool,v8::internal::Allocationorigin) [/Users/da/.nvm/versions/node/v12.16.3/bin/node]
13: 0x10063e698 v8::internal::Runtime_AllocateInYoungGeneration(int,unsigned long*,v8::internal::Isolate*) [/Users/da/.nvm/versions/node/v12.16.3/bin/node]
14: 0x10097cc39 Builtins_CEntry_Return1_DontSaveFPRegs_ArgvOnStack_NoBuiltinExit [/Users/da/.nvm/versions/node/v12.16.3/bin/node]
15: 0x10097dcd3 Builtins_StringAdd_CheckNone [/Users/da/.nvm/versions/node/v12.16.3/bin/node]
16: 0x26c80fc5e45b
17: 0x26c80fe6e097
Abort trap: 6
使用其他回购协议,我通过以下方式解决了此问题
An unhandled exception occurred: Cannot find module ''@angular-devkit/build-angular/package.json''
Require stack:
- /Users/da/*code*/ng-tests/node_modules/@angular-devkit/architect/node/node-modules-architect-host.js
- /Users/da/*code*/ng-tests/node_modules/@angular-devkit/architect/node/index.js
- /Users/da/*code*/ng-tests/node_modules/@angular/cli/models/architect-command.js
- /Users/da/*code*/ng-tests/node_modules/@angular/cli/commands/serve-impl.js
- /Users/da/*code*/ng-tests/node_modules/@angular-devkit/schematics/tools/export-ref.js
- /Users/da/*code*/ng-tests/node_modules/@angular-devkit/schematics/tools/index.js
- /Users/da/*code*/ng-tests/node_modules/@angular/cli/utilities/json-schema.js
- /Users/da/*code*/ng-tests/node_modules/@angular/cli/models/command-runner.js
- /Users/da/*code*/ng-tests/node_modules/@angular/cli/lib/cli/index.js
- /usr/local/lib/node_modules/@angular/cli/lib/init.js
- /usr/local/lib/node_modules/@angular/cli/bin/ng
See "/private/var/folders/f4/mlvzp1r55zs854sbj_bypf200000gn/T/ng-s5zwHm/angular-errors.log" for further details.
但是将该解决方案应用于我尝试访问的存储库,我得到了上面提到的首字母npm install --save-dev @angular-devkit/build-angular npm install ng serve -o
,然后回到了开始的地方。
解决方法
node --max_old_space_size=16192 ./node_modules/@angular/cli/bin/ng serve 尝试给它更多内存
关于将大数据集从列表转换为 numpy 数组时出现 numpy 内存错误和数据集转化为npy文件的介绍现已完结,谢谢您的耐心阅读,如果想了解更多关于"import numpy as np" ImportError: No module named numpy、16MB 版本上的 Micropython ESP32 内存错误、37 字节文件的pickle 内存错误、Angular 10 run ng服务获取webpack,内存错误的相关知识,请在本站寻找。
本文标签: