爽歪歪666
不以物喜,不以己悲,努力才是永恒的主题。
上一页 1 2 3 4 5 6 7 8 9 ··· 15 下一页
摘要: F.cross_entropy(x,y) 1 x = np.array([[1, 2,3,4,5], 2 [1, 2,3,4,5], 3 [1, 2,3,4,5]]).astype(np.float32) 4 y = np.array([1, 1, 0]) 5 x = torch.from_nump 阅读全文
posted @ 2020-05-26 19:59 爽歪歪666 阅读(4295) 评论(0) 推荐(0) 编辑
摘要: 1.one-hot编码 1 import numpy as np 2 from sklearn.preprocessing import OneHotEncoder 3 4 data = np.array([[1],[4]]) 5 ohe = OneHotEncoder(sparse=False,h 阅读全文
posted @ 2020-05-25 21:04 爽歪歪666 阅读(389) 评论(0) 推荐(0) 编辑
摘要: numpy中的ravel()、flatten()、squeeze()都有将多维数组转换为一维数组的功能,区别: ravel():如果没有必要,不会产生源数据的副本flatten():返回源数据的副本squeeze():只能对维数为1的维度降维 转载: https://blog.csdn.net/we 阅读全文
posted @ 2020-05-23 15:23 爽歪歪666 阅读(211) 评论(0) 推荐(0) 编辑
摘要: 1 import numpy as np 2 3 features = np.array([[1,2,3],[4,5,6],[7,8,9]]) 4 components = [True,True,True] 5 features = features[:, components] 6 print(f 阅读全文
posted @ 2020-05-18 09:53 爽歪歪666 阅读(236) 评论(0) 推荐(0) 编辑
摘要: 解决办法: 更新sklearn库 具体方法: 1.打开anaconda下的anaconda的Promote 2.输入 pip list 可以查看当前已经安装的包和版本 3.更新sklearn: 输入”conda update scikit-learn” 参考: https://blog.csdn.n 阅读全文
posted @ 2020-05-17 17:22 爽歪歪666 阅读(2491) 评论(0) 推荐(0) 编辑
摘要: 1.df6 = pd.DataFrame(data,index=行名,columns=列名)# 构成一个表格print(df6.index) # 查看行名print(df6.columns) # 查看列名print(df6.values) # 查看数据值print(df6['B'].values) 阅读全文
posted @ 2020-05-16 19:27 爽歪歪666 阅读(165) 评论(0) 推荐(0) 编辑
摘要: 题目描述 请实现一个函数用来判断字符串是否表示数值(包括整数和小数)。例如,字符串"+100","5e2","-123","3.1416"和"-1E-16"都表示数值。 但是"12e","1a3.14","1.2.3","+-5"和"12e+4.3"都不是。 思路: 分几种情况,括号代表可选 整数 阅读全文
posted @ 2020-05-11 12:55 爽歪歪666 阅读(164) 评论(0) 推荐(0) 编辑
摘要: 1.torch.rand()函数 均匀分布torch.rand(*sizes, out=None) → Tensor 返回一个张量,包含了从区间[0, 1)的均匀分布中抽取的一组随机数。张量的形状由参数sizes定义。 参数: sizes (int...) - 整数序列,定义了输出张量的形状out 阅读全文
posted @ 2020-05-10 19:09 爽歪歪666 阅读(232) 评论(0) 推荐(0) 编辑
摘要: 题目描述 将一个字符串转换成一个整数,要求不能使用字符串转换整数的库函数。 数值为0或者字符串不是一个合法的数值则返回0 输入描述: 输入一个字符串,包括数字字母符号,可以为空 输出描述: 如果是合法的数值表达则返回该数字,否则返回0 Python代码1: 1 # -*- coding:utf-8 阅读全文
posted @ 2020-05-08 12:28 爽歪歪666 阅读(474) 评论(0) 推荐(0) 编辑
摘要: 题目描述 写一个函数,求两个整数之和,要求在函数体内不得使用+、-、*、/四则运算符号。 思路: 异或:求各位之和 与:计算进位 Python代码 1 # -*- coding:utf-8 -*- 2 class Solution: 3 def Add(self, num1, num2): 4 # 阅读全文
posted @ 2020-05-06 12:18 爽歪歪666 阅读(671) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 9 ··· 15 下一页