首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么AI在PC上训练自定义模型的时间比我的笔记本还要长?

为什么AI在PC上训练自定义模型的时间比我的笔记本还要长?
EN

Stack Overflow用户
提问于 2022-07-28 00:20:08
回答 1查看 47关注 0票数 -1

我正在为分类做一个定制的训练模型--我在一台有2 CPU和32 RAM的电脑上测试了训练的模型,但是它比没有GPU的笔记本电脑8G Ram要慢,如屏幕截图所示,我的PC需要将近1小时,我的笔记本需要10分钟,为什么会这样呢?

这是我带windows 10 https://ibb.co/1zQn9Vm的笔记本电脑的屏幕

这是带有windows 11 https://ibb.co/j8WTTL0的PC的屏幕。

这是我的代码:

代码语言:javascript
复制
target = []
images =[]
flat_data =[]



DATADIR = r"Images"
CATEGORIES = ['cat1', 'cat2', 'cat3', 'cat4']

for cat in CATEGORIES:
class_num = CATEGORIES.index(cat)
path = os.path.join(DATADIR, cat)
for img in os.listdir(path):
  img2 = Image.open(os.path.join(path, img))
  compression_image = img2.info['compression']
  if(compression_image == 'group4'):
      img2.save(os.path.join(path, img), compression='tiff_lzw')                                                      
  img_array = imread(os.path.join(path, img))
  img_resized = resize(img_array, (200 , 200))
  flat_data.append(img_resized.flatten())
  images.append(img_resized)
  target.append(class_num)
  
  
 flat_data = np.array(flat_data)
 target = np.array(target)
 images = np.array(images)

 from sklearn.model_selection import  train_test_split
 x_train, x_test, y_train, y_test= train_test_split(flat_data, 
 target, test_size=0.3, random_state= 109)

 from sklearn.model_selection import  GridSearchCV
 from sklearn import svm

 param_grid = [
{'C': [1, 10, 100, 1000], 'kernel': ['linear']},
{'C': [1, 10, 100, 1000], 'gamma': [0.001, 0.0001], 'kernel': 
['rbf']}
]

svc = svm.SVC(probability= True)
clf = GridSearchCV(svc, param_grid)
clf.fit(x_train, y_train)
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-07-28 02:22:02

在我添加了这个参数之后,它工作得很好。

代码语言:javascript
复制
GridSearchCV try setting n_jobs=-1
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73145915

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档