- 博客(35)
- 收藏
- 关注
原创 2021-10-27 关于super().__init__() 继承父类
笔记自用1. 继承时,父类的属性也要定义在子类的super().__init__()中子类继承属性时,父类的dataname,bathsize这两个属性也要写在构造方法里面,如下TheSub类:子类只继承父类方法 时,不用将属性写进去‘’‘父类’‘’class TheSupeir: def __init__(self,dataname,batchsize): ‘’‘ 构造方法里面构造两个属性 ’‘’ self.dataname = dataname
2021-10-27 13:23:40
413
原创 2021/9/10在模型中定义连续线性变换函数的简便方法
代码import torchimport torch.nn as nnclass my_module(nn.Module): def __init__(self,*args): super(my_module, self).__init__() for block in args: self._modules[block] = block # self.linear = nn.Linear(2,3) #
2021-09-10 23:34:45
234
原创 win10 右键打开终端
随便一个地方创建一个文件,复制下列内容Windows Registry Editor Version 5.00[HKEY_CLASSES_ROOT\Directory\Background\shell\OpenCmdHere]@="open Terminal in here" [HKEY_CLASSES_ROOT\Directory\Background\shell\OpenCmdHere\command]@="cmd.exe -noexit -command Set-Location -.
2021-07-01 19:53:44
7187
原创 LongTensor的使用场景(未解决)
在读cs244n_pytorch_tutorial时,谈到创建张量时,文档说:longtensor在nlp中特别重要。原来如下LongTensors are particularly important in NLP as many methods that deal with indices require the indices to be passed as a LongTensor, which is a 64 bit integer.索引需要当作LongTensor传入------什么意思
2021-06-13 15:03:58
2431
1
原创 TypeError: object of type ‘type‘ has no len()
报错截图:原因:dataset = 后面写错了,应该跟一个已经实例化的Dataset对象正确代码:
2021-06-12 22:32:20
2281
原创 IndexError: too many indices for array
在对二维数组进行操作时,出现了:IndexError: too many indices for array原因:数据中,其中一个数组出现了空数组
2021-06-12 20:25:31
404
原创 torch中三种sigmoid使用方法
关于下面三种sigmoid的使用方法torch.sigmoid()torch.nn.functional.sigmoid()torch.Sigmoid相同点都是将值映射到0-1之间,没用区别不同点所属类型不同方法:torch.sigmoid() 和torch.nn.funtional.sigmoid()类:torch.Sigmoid使用方法不同两个方法函数直接传输向量就行,而类需要先定义一个类,然后再通过调用类本身的__call__函数去使用。a = torch.tens
2021-06-07 18:30:46
30140
1
原创 2021-05-30 skip-gram
skip-gramone-hot编码one-hot简介为了让词语能在电脑中,利用独热编码进行表示。one-hot缺点任意两个词的独热向量,正交为0;因为前者缺点,因此无法表示任意两个独热向量的天然联系。Word2Vec嵌入矩阵为了解决one-hot的缺点,引入嵌入矩阵,使得词向量均为dense vector,由诸多特征构成,特征够多,向量之间的联系与区别才会更丰富。没想好标题设ttt为center word的序号,同时令mmm为the window size of
2021-05-30 23:34:45
111
原创 vscode配置c的launch.json 和task.json
launch.json{ "version": "0.2.0", "configurations": [ { "name": "C/C++", "type": "cppdbg", "request": "launch", "program": "${fileDirname}/${fileBasenameNoExtension}.exe", "args":
2020-05-17 14:52:48
4476
1
原创 padnas 读取 txt文件
使用read_csv函数来读取csv、tsv、txt文件:格式:pandas.read_csv(数据文件名, sep=’,’, header=’infer’, names=None, index_col=None,dtype=None, engine=None, nrows=None)
2020-05-06 12:55:53
210
原创 pandas 拼接两个字段相同的列表
table_line=pd.concat([table_line,table_line1])#[ ]容易忘掉
2020-04-28 19:55:11
1898
原创 二维数组 转变为 pandas.Dataframe
直接将二维数组放到pd.DataFrame()zxc=np.zeros((10,24))pd.DataFrame(zxc)
2020-04-28 19:24:44
11794
原创 修改列名&将pd.Dataframe转化为列值之间的字典索引
修改列名table1.rename(columns={'locaton':'location'},inplace=True)将pd.Dataframe转化为列值之间的字典索引目标:将stationID 的值或者stationNAME 对location的值进行字典建立dic1=table1.set_index('stationID').to_dict()...
2020-04-18 19:07:11
825
原创 python报错问题—— xxx takes 1 positional argument but 2 were given
不能忽略这个self,如果写成def requests_url(url):,后面再给这个函数传参,python就会觉得你传了两个参数(第一个默认是self)
2020-02-14 20:20:17
7315
原创 python爬虫——requests.exceptions.InvalidHeader: Invalid return character or leading space in header: co
在使用requests库爬去淘宝时,在登录输入headers参数时,复制user-agent和cookis时多了空格。headers{‘cookie’: ’ uab_collina=157258226625083933457665; thw=cn; t=36d1cd24cf0143fb6accdf025534d197; enc=97GhrHhKkErSIlgzQuOf4gDv8yB1I...
2020-01-21 17:41:12
824
3
原创 python爬虫——爬去淘宝商品页面,总是跳转到登录界面
考虑到cookie的问题但是在headers={}中添加cookie 的信息,仍然跳转。时而跳转时而不跳转
2020-01-15 02:30:46
4503
4
原创 122 买股票的最佳时机ii
给定一个数组,它的第 i 个元素是一支给定股票第 i 天的价格。设计一个算法来计算你所能获取的最大利润。你可以尽可能地完成更多的交易(多次买卖一支股票)。注意:你不能同时参与多笔交易(你必须在再次购买前出售掉之前的股票)。示例 1:输入: [7,1,5,3,6,4]输出: 7解释: 在第 2 天(股票价格 = 1)的时候买入,在第 3 天(股票价格 = 5)的时候卖出, 这笔交易所能获...
2019-12-14 22:58:04
105
原创 121.买卖股票的最佳时机
给定一个数组,它的第 i 个元素是一支给定股票第 i 天的价格。如果你最多只允许完成一笔交易(即买入和卖出一支股票),设计一个算法来计算你所能获取的最大利润。注意你不能在买入股票前卖出股票。示例 1:输入: [7,1,5,3,6,4]输出: 5解释: 在第 2 天(股票价格 = 1)的时候买入,在第 5 天(股票价格 = 6)的时候卖出,最大利润 = 6-1 = 5 。注意利润不能是...
2019-12-13 19:29:48
100
原创 玩筹码
解题思路单数移动到单数 代价始终是0双数移动到双数 代价始终是0题目中数组中的123.代表位置。比如:[1,2,2,2,3,3] 代表 第一个位置有1个筹码,第二个位置有三个筹码,第三个位置有2个筹码。解题思路:将问题转化为,是单数位置上的筹码还是双数位置上的筹码少。代码class Solution { public int minCostToMoveChips(int[] ...
2019-12-12 19:03:51
154
原创 Java编译问题
1、在Eclipse动态web工程中,web-inf下创建classes且将java源码编译到此路径步骤 右键工程→properties→Java Build Path→Source→Default output folder
2019-12-10 14:58:18
103
原创 JavaScript,表单选中文件显示在页面上
function imgChange1(obj) {//获取点击的文本框 var file = document.getElementById("file1"); //通过表单input 的id获取元素 var imgUrl = window.URL.createObjectURL(file.files[0]);//不太懂 var img = document.getEl...
2019-12-04 01:15:39
345
原创 利用百度API,实现在网页的前后端分离预测图片
大概实现结果实现Jquery ajax代码 <script> $("#btn1").click(function () { //创建FormData对象 var formD...
2019-12-04 01:13:21
167
原创 数据结构——Floyd算法——顺序存储
#include<stdio.h>#include"structure.c"#define MaxVerTex 100typedef char Dis;//输出floyd中的矩阵void printDis_Floyd(AMGraph *G, int a[MaxVerTex][MaxVerTex]){ for (int i = 0; i < ...
2019-11-25 19:19:54
209
原创 数据结构——Dijkstra算法——顺序存储
#include<stdio.h>#include"structure.c"typedef struct dist{ VerTaxType vexs; int dist;}dist;typedef struct path{ VerTaxType vexs; VerTaxType path;...
2019-11-25 17:59:32
385
原创 数据结构——邻接矩阵——顺序存储
#include<stdio.h>#define MaxVerTax 100#define MaxInt 32767 //定义边的权重值typedef char VerTaxType; //节点类型typedef int AcrType;//边的类型typedef struct AdjMatrix { //定义节点数组 Ve...
2019-11-24 21:21:33
554
转载 关于scanf("%[^\n]",str)的输入问题
int n;char string[20][100];scanf("%d", &n);for (int i = 0; i < n; i++){ int count=0; getchar(); scanf("%[^\n]", string[i]); for (int j = 0; j < strlen(string[i]); j++) { if ((stri...
2019-11-24 21:20:15
443
原创 内部Servlet请求转发到JSP后页面的JS,CSS等资源引入问题
Conclusionsolution 1:the principle of Path_ProblemKey 1:Afterwards Servlet forward the request to JSP,the relative path of JSP will become the same as the relative path of Servlet,which means if i...
2019-11-23 02:18:16
267
转载 getParameter和getAttribute区别(超详细分析)
getParameter和getAttribute区别(超详细分析)对getParameter过程,如下图:对getAttribute过程,如下图:两者区别:①getParameter()获取的是客户端设置的数据。getAttribute()获取的是服务器设置的数据。②getParameter()永远返回字符串getAttribute()返回值是任意类型既然parameter和at...
2019-11-22 15:06:07
90
转载 怎么删除右键出现Open Folder as Intellij IDEA Project
原文链接首先,Win+R 输入 regedit (注册表编辑器),然后按Enter。1.右键单击文件夹背景时(出现的情况):在注册表中打开“ 计算机 \ HKEY_CLASSES_ROOT \ Directory \ Background \ shell \ IDEA Community ”。删除整个“IDEA Community”文件夹。2.右键单击文件图标时(出现的情况):在注册表...
2019-11-12 22:52:39
7203
4
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人