雪山飞狐W
把时间浪费在美好的算法上~
励志做一名有社会价值和自我价值的人,用代码改变生活。
爱生活、爱自由,特立独行。
工作联系:wx_ai97@163.com
展开
-
Pytorch Error 常见总结
Pytorch Error1-输入数据维度不同Pytorch Error:invalid argument 0: Sizes of tensors must match except in dimension 0. Got 62 and 56 i2-模型中shape不一致Pytorch Error: ValueError: Expected input batch_size (324) to match target batch_size (4) Log In3-分类时crossEntropyLo原创 2020-06-24 16:01:43 · 432 阅读 · 0 评论 -
Pytorch Erroe:invalid argument 0: Sizes of tensors must match except in dimension 0. Got 62 and 56 i
Errorinvalid argument 0: Sizes of tensors must match except in dimension 0. Got 62 and 56 in dimension 2 at C:\Users\builder\AppData\Local\Temp\pip-req-build-9msmi1s9\aten\src\TH/generic/THTensor.cpp...原创 2020-03-20 22:53:07 · 467 阅读 · 0 评论 -
Pytorch Error: ValueError: Expected input batch_size (324) to match target batch_size (4) Log In
ERROR运行到loss = criterion(output, target)时报错:ValueError: Expected input batch_size (324) to match target batch_size (4) Log In解决方法打印class Net(nn.Module): def __init__(self): super(Ne...原创 2020-03-19 18:42:54 · 10834 阅读 · 8 评论 -
Pytorch Error:RuntimeError: Assertion cur_target 0 cur_target n_classes failed
ERROR使用pytorch的函数 torch.nn.CrossEntropyLoss()计算Loss时报错或者loss = criterion(output, target)报错:RuntimeError: Assertion `cur_target >= 0 && cur_target < n_classes' failed解决方法:原因一:模型输出...原创 2020-03-19 18:35:39 · 967 阅读 · 0 评论 -
python-AttributeError: module 'matplotlib' has no attribute 'contourf'
错误内容Traceback (most recent call last): File "C:/Users/雪山飞狐/Desktop/学习总结/ML100天/Code/Day_4.py", line 30, in <module> plt.contourf(X1, X2, classifer.predict(np.array([X1.ravel(), X2.ravel()...原创 2019-10-21 21:21:44 · 3924 阅读 · 0 评论 -
算法-聚类-K均值与模糊K均值:原理+python代码
['DESCR', 'data', 'feature_names', 'filename', 'target', 'target_names'].. _iris_dataset:Iris plants dataset--------------------**Data Set Characteristics:** :Number of Instances: 150 (50 i...原创 2019-10-21 18:51:01 · 5137 阅读 · 7 评论 -
python-opencv-matplotlib灰度图可视化处理
参考文章1、golgotha的ttps://www.jianshu.com/p/de9013f181d7一、Demo一、1.热度图利用matplotlib可视化一张图片的灰度图。纵横坐标为图片的像素点位置(x, y),此像素点的灰度值z(x, y)当作z轴上的取值。首先利用plot_surface分析某张图片的灰度图import matplotlib.pyplot as pltf...原创 2019-09-28 14:21:02 · 1631 阅读 · 0 评论 -
python-opencv-ValueError: setting an array element with a sequence
Error描述C:\WORK\Python\python.exe C:/Users/雪山飞狐/Desktop/研究生资料/数字图像处理/shiyan1.pyTraceback (most recent call last): File "C:/Users/雪山飞狐/Desktop/研究生资料/数字图像处理/shiyan1.py", line 23, in <module> ...原创 2019-09-19 17:36:10 · 803 阅读 · 0 评论 -
cv2.error: OpenCV(4.1.0) C:\projects\opencv-python\opencv\modules\imgproc\src\segmentation.cpp:161:
问题描述在运用分水岭分割的时候,发现该常见错误kernel = np.ones((3, 3), np.uint8)sure_bg = cv.dilate(waterimg, kernel, iterations=3)# 确定背景dist = cv.distanceTransform(waterimg, cv.DIST_L2, 3)# 距离变换ret, sure_fg = cv.thres...原创 2019-08-23 18:03:50 · 36687 阅读 · 48 评论 -
python-[简单训练3]-搜索当前文件夹属于一类的所有文件,检查序号是否连续,不连续则修改(消除缺失的编号)
问题描述在一个文件夹中,找到所有带指定前缀的文件,例如:spam001.txt定位缺失的编号,让程序对后面所有的文件改名,消除缺失的编号代码如下:import os, re, shutilcuurentdir = os.getcwd()textname = [] #储存符合要求的文件名称for filename in os.listdir('.'): mo = re.c...原创 2019-08-07 17:00:53 · 618 阅读 · 0 评论 -
python-[简单训练2]-搜索当前文件夹所有的.txt文件,对用户输入的正则表达式进行搜索并进行显示
问题描述打开文件夹中的所有.txt文件,查找匹配用户提供的正则表达式的所有行,并将结果输出在屏幕上代码如下:import osimport refindtxt = re.compile(r'[0-9a-zA-Z]+\.txt')d = []for filename in os.listdir(os.getcwd()): f = findtxt.search(file...原创 2019-08-07 11:39:21 · 1003 阅读 · 0 评论 -
python-[openpyxl]-代码更改后
https://blog.51cto.com/daimalaobing/2089686转发的转发的转发的,当作收藏openpyxl模块介绍openpyxl模块是一个读写Excel 2010文档的Python库,如果要处理更早格式的Excel文档,需要用到额外的库,openpyxl是一个比较综合的工具,能够同时读取和修改Excel文档。其他很多的与Excel相关的项目基本只支持读或者写Exc...转载 2019-08-09 10:10:01 · 312 阅读 · 0 评论 -
给pycharm快速添加Opencv库
前提1.安装好python,已经配置好环境.2.安装好pycharm,配置好python注意:未安装这些软件的话可以直接百度或者csdn搜索下载流程1.找到python的源文件夹,打开可以看到pip2.然后运行cmd输入:有这种界面出现就算是正常的。3.现在输入pip install opencv-python 按下回车开始下载最新的opencv.4 开始测试im...原创 2019-07-30 19:58:51 · 14521 阅读 · 2 评论 -
python-[简单训练1]-对于输入的单词用','分开,对再输入的字母进行搜索,得到该字母出现频率最高的单词
刚开始学python,应用一些简单的问题熟悉下各个基本内容问题描述输入多个单词,每个单词之间用英文逗号隔开,再输入要查询的字母,得到该字母出现频率最高的单词代码内容:count = []print('Please input your something : ')message = input()i = 0str = ''#将各个单词存储到列表内for a in ra...原创 2019-08-02 15:23:08 · 1028 阅读 · 0 评论