Python
mznfirst
科技改变生活,代码创造未来!
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
使用Python Matplotlib库绘制直方图、曲线图和折线图
将数据保存在excel表格中,用xlrd读取xlsx表格文件中的数据,将之绘图。 首先安装依赖库 Matplotlib 3.0+ does not support Python 2.x, 3.0, 3.1, 3.2, 3.3, or 3.4. Beginning with Matplotlib 3.0, Python 3.5 and above is required. pip3 install ...原创 2019-06-13 17:04:45 · 284 阅读 · 0 评论 -
Python笔记1
1. 转换Python list类型为numpy数组 先定义一个list列表,然后用np.ndarray来转换 k = [[0,2,1],[0,1,0],[0,0,1]] ret = np.asarray(k) 2. 变量相乘和矩阵相乘 #-*- coding:utf-8 -*- import numpy as np a = np.array([[1,1], [0,1...原创 2019-01-04 16:50:01 · 151 阅读 · 1 评论 -
Pytorch 笔记 -- model模型
1. 保存载入模型 import torch torch.save(model,'model_name') #将网络模型、模型参数全部保存 torc.save(model.state_dict(),'model_name.pkl') #只保存模型参数 两种载入方式也不相同 torch.load('model_name') from torchvision import models mod...原创 2019-01-04 17:17:36 · 946 阅读 · 0 评论 -
Pytorch 对nn.Parameter类型变量赋值bug
在使用Pytorch赋值过程中有一些小细节需要注意。 先出示实验结果 初始化一个值为1的tensor torch.Tensor([1]) 正确的赋值方式: w.data[0]=a 实验记录 In [1]: import torch # 初始化参数 w,a ,b, In [2]: w = torch.nn.Parameter(torch.zeros(4)) In [3]: w Out[3]:...原创 2019-03-28 14:58:10 · 5510 阅读 · 1 评论
分享