
HKUST pytorch zero to all
文章平均质量分 73
努力奋斗-不断进化
认真
展开
-
Lec2: Linear model
import torchimport numpy as npimport matplotlib.pyplot as pltx_data = [1.0, 2.0, 3.0]y_data = [2.0, 4.0, 6.0]# our model for the forward passdef forward(x): return x * w# loss function...原创 2018-05-20 09:02:43 · 255 阅读 · 0 评论 -
PyTorch Lecture12:RNN1 - Basics (代码12_3_hello_rnn_seq)
# 12_3_hello_rnn_seqimport torchimport torch.nn as nnfrom torch.autograd import Variabletorch.manual_seed(777) # reproducibility# 0 1 2 3 4idx2cahr = ['h', 'i', 'e', 'l...原创 2018-06-16 15:15:00 · 231 阅读 · 0 评论 -
PyTorch Lecture12:RNN1 - Basics
原作者给出的代码运行的时候存在一个问题:TypeError: list indices must be integers or slices, not torch.LongTensor出错的地方在:sys.stdout.write(idx2char[idx.data[0]])sys.stdout.write(idx2char[idx.data[0]])修改为为:sys.stdout.write(i...原创 2018-06-16 11:05:55 · 217 阅读 · 0 评论 -
PyTorch Lecture12:RNN1 - Basics
代码1import torchimport torch.nn as nnfrom torch.autograd import Variable# One hot encoding for each char in 'hello'h = [1, 0, 0, 0]e = [0, 1, 0, 0]l = [0, 0, 1, 0]o = [0, 0, 0, 1]# One cell R...原创 2018-06-16 11:02:48 · 210 阅读 · 0 评论 -
PyTorch Lecture11 Advanced CNN (Inception modules)(HKUST)
实现Inception modules相关文章使用GPU运算from __future__ import print_functionimport argparseimport torchimport torch.nn as nnimport torch.nn.functional as Fimport torch.optim as optimfrom torchvision impo...原创 2018-06-14 16:41:46 · 387 阅读 · 1 评论 -
PyTorch Lecture 10: Basic CNN
from __future__ import print_functionimport argparseimport torchimport torch.nn as nnimport torch.nn.functional as Fimport torch.optim as optimfrom torchvision import datasets, transformsfrom t...原创 2018-05-23 09:23:31 · 280 阅读 · 0 评论 -
解决办法 pred = torch.max(a,1,keepdim=True)[1]
pred = torch.max(a,1,keepdim=True)[1]TypeError: torch.max received an invalid combination of arguments - got (torch.LongTensor, int, keepdim=bool), but expected one of: * (torch.LongTensor source) * (...原创 2018-05-21 18:20:31 · 21984 阅读 · 0 评论 -
PyTorch Lecture 09: Softmax Classifier
from __future__ import print_functionimport torchimport torch.nn as nnimport torch.nn.functional as Fimport torch.optim as optimfrom torchvision import datasets, transformsfrom torch.autograd i...原创 2018-05-21 18:18:00 · 311 阅读 · 1 评论 -
PyTorch Lecture 08: PyTorch DataLoader
# References# https://github.com/yunjey/pytorch-tutorial/blob/master/tutorials/01-basics/pytorch_basics/main.py# http://pytorch.org/tutorials/beginner/data_loading_tutorial.html#dataset-classimport...原创 2018-05-21 10:16:49 · 384 阅读 · 0 评论 -
PyTorch Lecture 07: Wide and Deep
纠正了作者代码中个的一个问题,即看数据大小的代码import torchfrom torch.autograd import Variableimport numpy as npxy = np.loadtxt('./data/diabetes.csv.gz', delimiter=',', dtype=np.float32)x_data = Variable(torch.from_num...原创 2018-05-21 09:17:26 · 3477 阅读 · 2 评论 -
PyTorch Lecture 06: Logistic Regression
记住常用的句型(用多了,应该就记住了)import torchfrom torch.autograd import Variableimport torch.nn.functional as Fx_data = Variable(torch.Tensor([[1.0], [2.0], [3.0], [4.0]]))y_data = Variable(torch.Tensor([[0],...原创 2018-05-20 17:18:00 · 654 阅读 · 0 评论 -
PyTorch Lecture 05: Linear Regression in the PyTorch way
几个步骤要记住1.Design your model using class、2.Construct loss and optimizer (select from PyTorch API)3. Training cycle (forward, backward, update)(同时写代码的时候,一定要对齐)import torchfrom torch.autograd import Var...原创 2018-05-20 16:02:19 · 293 阅读 · 0 评论 -
PyTorch Lecture 04: Back-propagation and Autograd
import torchfrom torch import nnfrom torch.autograd import Variablex_data = [1.0, 2.0, 3.0]y_data = [2.0, 4.0, 6.0]w = Variable(torch.Tensor([1.0]), requires_grad=True) # Any random valueprint...原创 2018-05-20 14:49:44 · 359 阅读 · 0 评论 -
PyTorch Lecture12:RNN1 - Basics (代码12_4_hello_rnn_emb)
# Lab 12 RNNimport torchimport torch.nn as nnfrom torch.autograd import Variabletorch.manual_seed(777)idx2char = ['h', 'i', 'e', 'l', 'o']# Tech hihell->ihellox_data = [[0, 1, 0, 2, 3, 3]...原创 2018-06-16 15:41:55 · 264 阅读 · 0 评论