【发布时间】:2019-01-08 16:00:20
【问题描述】:
如果我运行此代码,我会收到内存错误。有谁知道我可以改进什么?
代码:
import numpy as np
import matplotlib.pyplot as plt
from sklearn import datasets
from sklearn.gaussian_process import GaussianProcessClassifier
from sklearn.gaussian_process.kernels import RBF
import cv2
input = "testProbe.jpg"
# load the image, convert it to grayscale
image = cv2.imread(input)
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
# threshold the image to reveal light regions in the gray image
thresh = cv2.threshold(gray, 145, 200, cv2.THRESH_BINARY)[1]
# import data
X = np.where(thresh>0)
xx = np.array(X)
xx = np.ravel(xx,order='F')
zz = xx.reshape((int(len(xx)/2),2))
y = np.asarray(np.zeros((widthX, 1), dtype=int))
在这里我编辑 y 来处理数据并获得第二个数据集。
y[1:5] = 1
当我运行这段代码时,出现错误:
gpc_rbf_isotropic = GaussianProcessClassifier().fit(zz, y)
【问题讨论】:
-
你的数据集有多大?
-
@GabrielM 大小为 338742
标签: python python-3.x memory scikit-learn out-of-memory