
python
風中塵埃
这个作者很懒,什么都没留下…
展开
-
记录参加DataWhale的CV实践_语义分割--赛题理解与baseline
赛题:地址:https://tianchi.aliyun.com/competition/entrance/531872/information原创 2021-03-01 13:00:18 · 270 阅读 · 1 评论 -
用pytorch实现一个简单的线性回归模型
我们使用pytorch实现一个简单的线性回归模型。(我是在jupyter notebook下做的,建议在这个环境下写代码)首先我们先定义数据集:#数据集中的样本值x = [35.7, 55.9, 58.2, 81.9, 56.3, 48.9, 33.9, 21.8, 48.4, 60.4, 68.4]#数据集中的标签y = [0.5, 14.0, 15.0, 28.0, 11.0, 8.0, 3.0, -4.0, 6.0, 13.0, 21.0]x = torch.tens原创 2021-01-01 18:02:17 · 676 阅读 · 1 评论 -
pytorch代码示例笔记 -- Autograd
这篇博文是我记录学习pytorch的一些代码例子,我会时不时来看这些代码加深学习例子来自https://pytorch.org/tutorials/beginner/pytorch_with_examples.htmlimport torchimport mathdtype = torch.floatdevice = torch.device("cpu")x = torch.linspace(-math.pi, math.pi, 2000, dt原创 2020-12-30 01:43:19 · 448 阅读 · 4 评论 -
读libsvm数据文件(几行代码解决)
首先将libsvm数据文件格式改成txt文件格式。然后代码如下:from sklearn.datasets import load_svmlight_fileX_train, y_train = load_svmlight_file("housing_scale.txt")原创 2020-12-27 21:19:56 · 664 阅读 · 1 评论 -
将libsvm文件转换为csv文件
import sysimport csvimport numpy as npdef empty_table(input_file): max_feature = 0 count = 0 with open(input_file, 'r', newline='') as f: reader = csv.reader(f, delimiter=" ") for line in reader: count += .原创 2020-12-14 20:41:01 · 547 阅读 · 0 评论 -
python去除文本中html标签
例子如下:现将以上文本从列表转换为字符串。代码如下:b = ''.join(a)效果如下:利用正则表达式去除html标签。代码如下:import rec = re.sub('<[^<]+?>', '', b).replace('\n', '').strip()效果如下:总代码如下:import rea = response...原创 2019-01-07 22:08:46 · 15695 阅读 · 2 评论