报错主要是TypeError: pic should be Tensor or ndarray. Got
也就是图片未被转换成Tensor,或者是ndarray,而现在我们需要Tesnsor。
Traceback (most recent call last):
File "mnt/Projects/baseline_cloud/src/train_model.py", line 281, in <module>
main(parser.parse_args())
File "mnt/Projects/baseline_cloud/src/train_model.py", line 183, in main
train_model(model, criterion, args, optimizer, train_loader, valid_loader)
File "mnt/Projects/baseline_cloud/src/train_model.py", line 212, in train_model
trainer.train(train_loader, optimizer)
File "/mnt/Projects/baseline_cloud/src/utils/trainers.py", line 31, in train
for i, inputs in enumerate(data_loader, 1):
File "/root/miniconda3/envs/myconda/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 517, in __next__
data = self._next_data()
File "/root/miniconda3/envs/myconda/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 557, in _next_data
data = self._dataset_fetcher.fetch(index) # may raise StopIteration
File "/root/miniconda3/envs/myconda/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 44, in fetch
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/root/miniconda3/envs/myconda/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 44, in <listcomp>
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/mnt/Projects/baseline_cloud/src/utils/preprocessor.py", line 19, in __getitem__
return self._get_single_item(indices)
File "/mnt/Projects/baseline_cloud/src/utils/preprocessor.py", line 23, in _get_single_item
img_path, label = self.img_paths_label[index]
File "/root/miniconda3/envs/myconda/lib/python3.7/site-packages/torchvision/datasets/folder.py", line 180, in __getitem__
sample = self.transform(sample)
File "/root/miniconda3/envs/myconda/lib/python3.7/site-packages/torchvision/transforms/transforms.py", line 60, in __call__
img = t(img)
File "/root/miniconda3/envs/myconda/lib/python3.7/site-packages/torchvision/transforms/transforms.py", line 179, in __call__
return F.to_pil_image(pic, self.mode)
File "/root/miniconda3/envs/myconda/lib/python3.7/site-packages/torchvision/transforms/functional.py", line 219, in to_pil_image
raise TypeError('pic should be Tensor or ndarray. Got {}.'.format(type(pic)))
TypeError: pic should be Tensor or ndarray. Got <class 'PIL.Image.Image'>.
train_transformer = T.Compose([
T.ToPILImage(),
T.RandomHorizontalFlip(), # 水平翻转
T.RandomRotation(10), # 随机旋转10度
T.ToTensor(),
normalizer,
])
可以看到最后一步是将前面的数据转成Tensor。
所以怀疑是T.ToPILImage()出现问题,画蛇添足了。去掉T.ToPILImage()后能成功。
一般是Transformer转换步骤有问题,transformer中没有T.ToTensor(),加上此语句。如果存在重复步骤(像如我的T.ToPILImage())去掉。
Pentaho按照Pentaho的下载与安装及其简单实用安装后连接mysql时报错。
1.显示缺少驱动
下载mysql对应驱动复制到data-integration\lib
下即可
mysql5.1.47connector
版本问题参考MySQL 5.7 等高版本关于JDBC驱动的几个问题
2.显示错误
The last packet successfully received from the server was 2 milliseconds ago. The last packet sent successfully to the server was 0 milliseconds ago.
部分参考Communications link failure 原因:The last packet successfully received from the server
这个问题是我碰到的问题,mysql5.7.32,驱动选择5.1.47是报错,后来想到当时是使用installers安装的全套,所以找到C:\Program Files (x86)\MySQL\Connector J 8.0
,将mysql-connector-java-8.0.22.jar复制到data-integration\lib
然后下一步
3.继续报错
Connection failed. Verify all connection parameters and confirm that the appropriate driver is installed. The server time zone value '�й���ʱ��' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.
可能是笔记本的时区与 kettle 框架有冲突,显示无法识别和保持多个时区,在命令行运行
mysql -u root -p
输入密码登录后,设置时区
show variables like '%time_zone%';
set global time_zone='+8:00';
多出的目录为系统自带.ipynb_checkpoints,可以到每个分类目录下,使用cd .i +TAB键补全的方式 判断是否存在该目录,有的话rm -rf .ipynb_checkpoints删除