- 博客(24)
- 收藏
- 关注
原创 cv2 运行bug 解决
参考文章:https://blog.csdn.net/z704630835/article/details/124564044。1.删除原来的opencv包:pip uninstall opencv-python。个人试着用pip、清华源的安装,都安装不上。直接用codna安装就可以了。2.重新安装opencv:conda install py-opencv。
2023-08-03 21:23:18 823
原创 训练过程中准确率、损失不变
交叉熵损失函数内置了softmax。我在编写网络的时候并不知道该功能,所以模型的最后一层多写了一层softmax,把这一层去掉,代码基本上就没问题了。问题描述:图像三分类,训练过程中准确率、损失均不变。解决办法:把代码全部看了一遍,发现是损失函数的问题。
2023-06-17 20:15:31 371
原创 策略梯度算法
这个博客讲的比较全面,还没仔细看,先马。博客网站:https://lilianweng.github.io/lil-log/2018/04/08/policy-gradient-algorithms.html
2021-08-23 16:09:26 73
原创 Endnote:无效的类字符串
在word中使用endnote插入参考文件的时候,点击插入引文一直出现“无效的类字符串”的问题。我用的是EndnoteX7版本,解决方法如下:在安装的文件件内找到“EndNoteX7Portable.exe”,运行之后,就可以正常使用了;看别人说,如果没有“EndNoteX7Portable.exe”,可以运行一下“Configure EndNote.exe”。由于方法1已经成功,所以就没有尝试方法2,故存在一定的不确定性,可做尝试。...
2021-07-17 21:50:05 7969
原创 英语语法知识点
这篇文章主要用来整理总结一些自己在写论文中遇到的不清楚的语法点。as和when的区别以下知识点摘自本网址在时间状语从句中,when和延续性动词、短暂性动词连用,as只和延续性动词连用;as强调主、从句的动作同时发生,when指主、从句动作同时或先后发生;when引导让步状语从句,意为“尽管”相当于though或although,as引导让步状语从句必须倒装。在时间状语从句中的用法与区别。...
2021-06-18 09:58:01 194
原创 组会PPT
1.PPT素材网https://ibaotu.com/ppt/http://www.1ppt.com/2.PPT教程http://www.tretars.com/不定期更
2021-05-26 10:09:05 185
原创 sklearn tsne
采用tsne画数据集的分布图from sklearn.manifold import TSNEimport numpy as npimport timeimport matplotlib.pyplot as pltimport pandas as pd# fig = plt.figure()# ax = fig.add_subplot(1, 1, 1, projection='3d')# for i in range(X.shape[0]):# a
2021-05-09 19:59:38 414
原创 TXT转CSV python
import numpy as npimport pandas as pdname = ['leukemia']for i in range(len(name)): txt = np.loadtxt('C:/Users/lenovo/' + name[i] + '.txt') txtDF = pd.DataFrame(txt) txtDF.to_csv('C:/Users/lenovo/' + name[i] + '.csv', in
2021-04-25 17:12:17 87
原创 求list均值
import numpy as npmean_accuracy = []a = 3for i in range(a): mean_accuracy.append(i)mean_acc = np.mean(mean_accuracy)
2021-04-25 16:18:25 467
原创 正态分布
粒子群算法里面的位置改进def gaussian_distribution(x, y): variance = abs(x-y) mean = (x+y)/2 f_x = np.random.normal(mean, variance) return f_x# 后面用到参数里面new_pos = (gaussian_distribution(p._personalBest, gbest_position) > np.random.random())*1..
2021-04-23 10:16:42 198
转载 Python3找出List中最大_最小的N个数及索引
https://www.cnblogs.com/xinmomoyan/p/10297590.html
2021-04-20 15:46:34 370
原创 ValueError: n_splits=4 cannot be greater than the number of members in each class
使用sklearn中cross_val_score()函数进行K折交叉验证时遇到以下bug:ValueError: n_splits=4 cannot be greater than the number of members in each class错误的原因:设置的折数大于每个类的样本数。目前没解决:自己两个程序里面用的准确率评估一样,pso+q可以使用,pso原始的方法用不了。...
2021-04-19 10:16:04 2558
原创 0、1取反 python
解决问题:想让一个array中的1、0值取反import numpy as npa = np.array([1,1,0,0,0,1])where_0 = np.where(a == 0)where_1 = np.where(a == 1)b = ab[where_0] = 1b[where_1] = 0print(b)结果:[0 0 1 1 1 0]
2021-04-16 15:28:17 2645
原创 采用deque判断连续N次迭代是否全部相同 python
解决问题:为了解决实验中 连续十次迭代中没有提高,算法停止 的要求解决办法:采用deque解决。deque在达到设定值的时候,可以将最前面的值剔除,让新的值加入。下面的代码是测试deque中的值是否完全相同,deque用于添加值,set函数用来实现判断功能。a = [1,1,1,1,1]de = deque(maxlen=5)for i in range(len(a)): de.append(a[i])if len(set(de))==1: print(1)else:
2021-04-16 09:59:01 131
原创 绘图及保存
matplotlib绘图及保存import matplotlib.pyplot as pltfig, ax = plt.subplots()plt.plot()ax.plot(x, curve, 'o-')ax.set_xlabel('Number of Iterations')ax.set_ylabel('...')ax.set_title('The process of ...')ax.grid()plt.show()plt.savefig('C:/Users.jpg')...
2021-04-15 21:24:10 62
原创 mat转csv python
import numpy as npimport scipy.io as scioimport h5pyname = ['9_Tumors', '11_Tumors', 'Brain_Tumor1', 'Brain_Tumor2', 'DLBCL', 'Leukemia1', 'SRBCT']for i in range(len(name)): datapath = 'C:/Users/' + name[i] + '.mat' print(file.keys()) file
2021-04-15 16:08:16 293
原创 分类器 代码
KNN分类器 十折交叉验证from sklearn.model_selection import StratifiedKFold, LeaveOneOut def fit(self, feature): kf = StratifiedKFold(n_splits=10) score_list = [] clf = KNeighborsClassifier(n_neighbors=1) for train, test in kf.split(fe
2021-04-15 11:05:33 265
原创 计算运行时间 python
#1.time方法代码: import time starttime = time.time() endtime = time.time() total_time = endtime - starttime print('time', total_time) ``` 结果:用秒来显示time -12.076830863952637```#2.datetime方法```import datatime starttime = datetime.da
2021-04-14 14:25:23 88
原创 IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boo
Bug:IndexError: only integers, slices (:), ellipsis (...), numpy.newaxis (None) and integer or bool出现位置:Q表更新的地方,索引设置不对。解决方法:numpy 处理的时候,注意索引不要用非整数。
2021-04-14 10:36:48 1540
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人