人工智能学习07--pytorch08--小汇总(newProject、(pytorch)、tensorboard、opencv-python、scipy、matplotlib、tqdm)

文章讲述了如何在PyCharm中创建新项目,导入PyTorch并展示基本操作。同时,它提到了如何设置终端为CMD,以及安装Tensorboard、OpenCV、Scipy、Matplotlib和TQDM等库。在使用数据加载器时遇到的问题和解决方法也被提及,包括修改迭代器的调用方式以避免AttributeError。此外,还介绍了将图像转换为RGB模式进行处理的方法。

pycharm:

new Project

在这里插入图片描述

import torch
import numpy as np
arr=np.ones((3,3))
print("arr的数据类型为:"+str(arr.dtype))
t=torch.tensor(arr)
print(t)

terminal调出(pytorch)

1、file-settings-Tools-terminal-shell path改成cmd那个
在这里插入图片描述
2、或者:在local旁边的下箭头选择command prompt 但是这个我没试过
重启pycharm就好了

tensorboard

要在(pytorch)里面下载
pip install tensorboard -i https://pypi.douban.com/simple/
,然后pip list就能看到

opencv-python

pip install opencv-python -i https://pypi.douban.com/simple/

scipy

pip install scipy -i https://pypi.douban.com/simple/

matplotlib

pip install matplotlib -i https://pypi.douban.com/simple/

tqdm

pip install tqdm -i https://pypi.douban.com/simple/

WZ老师代码

1、num_workers

在这里插入图片描述

2、.next()

AttributeError:‘_SingleProcessDataLoaderIter’ object has no attribute ‘next’
在这里插入图片描述

	# test_image, test_label = test_data_iter.next()
    test_image, test_label = next(test_data_iter)
    test_image, test_label = test_data_iter.__next__()

3、改matplotlib后端

紧接着出现新的错误
在这里插入图片描述
在这里插入图片描述

import matplotlib
print(matplotlib.get_backend())
matplotlib.use('TkAgg')

4、转RGB模式 predict

img = Image.open(img_path).convert('RGB')

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值