随笔分类 -  深度学习

摘要:import math import torch from torch import nn import matplotlib.pyplot as plt from d2l import torch as d2l def sequence_mask(X, valid_len, value=0): " 阅读全文 »
posted @ 2023-10-10 18:11 o-Sakurajimamai-o 阅读(17) 评论(0) 推荐(0) 编辑
摘要:注意力实现: import math import torch from torch import nn import matplotlib.pyplot as plt from d2l import torch as d2l def sequence_mask(X, valid_len, valu 阅读全文 »
posted @ 2023-09-21 17:17 o-Sakurajimamai-o 阅读(9) 评论(0) 推荐(0) 编辑
摘要:# Seq2seq # 进行机器翻译 import collections import math import os import torch from torch import nn from d2l import torch as d2l import matplotlib.pyplot as 阅读全文 »
posted @ 2023-09-17 16:37 o-Sakurajimamai-o 阅读(58) 评论(0) 推荐(0) 编辑
摘要:import os import torch from d2l import torch as d2l # @save d2l.DATA_HUB['fra-eng'] = (d2l.DATA_URL + 'fra-eng.zip', '94646ad1522d915e7b0f9296181140ed 阅读全文 »
posted @ 2023-09-11 19:58 o-Sakurajimamai-o 阅读(38) 评论(0) 推荐(0) 编辑
摘要:import torch from torch import nn from d2l import torch as d2l batch_size, num_steps = 32, 35 train_iter, vocab = d2l.load_data_time_machine(batch_siz 阅读全文 »
posted @ 2023-09-09 18:17 o-Sakurajimamai-o 阅读(261) 评论(0) 推荐(0) 编辑
摘要:从零开始实现RNN: import math import torch from torch import nn from torch.nn import functional as F import matplotlib.pyplot as plt from d2l import torch as 阅读全文 »
posted @ 2023-09-05 20:46 o-Sakurajimamai-o 阅读(17) 评论(0) 推荐(0) 编辑
摘要:循环神经网络 from mxnet import nd x, w_xh = nd.random.normal(shape=(3, 1)), nd.random.normal(shape=(1, 4)) h, w_hh = nd.random.normal(shape=(3, 4)), nd.rand 阅读全文 »
posted @ 2023-08-27 16:57 o-Sakurajimamai-o 阅读(32) 评论(0) 推荐(0) 编辑
摘要:# 灵活运用gluon实现神经网络 from mxnet import nd from mxnet.gluon import nn net = nn.Sequential() # net.name_scope()创建了一个名为net的命名空间,所有在with语句块中添加到net中的层都会包含在这个命 阅读全文 »
posted @ 2023-08-06 12:28 o-Sakurajimamai-o 阅读(11) 评论(0) 推荐(0) 编辑
摘要:LeNet: # LeNet import d2lzh as d2l import mxnet as mx from mxnet import autograd, gluon, init, nd from mxnet.gluon import loss as gloss, nn import tim 阅读全文 »
posted @ 2023-08-04 15:55 o-Sakurajimamai-o 阅读(63) 评论(0) 推荐(0) 编辑
摘要:二维卷积层: from mxnet import autograd, nd from mxnet.gluon import nn # 定义函数corr2d,用于实现二维卷积操作 def corr2d(x, k): # 获取卷积核的高度和宽度 h, w = k.shape # 初始化输出y,其形状为( 阅读全文 »
posted @ 2023-08-01 16:56 o-Sakurajimamai-o 阅读(39) 评论(0) 推荐(0) 编辑
摘要:# 线性回归 # 创建数据集 from mxnet import ndarray as nd from mxnet import autograd as ad num_input = 2 num_examples = 1000 true_w = [2, -3.4] true_b = 4.2 x = 阅读全文 »
posted @ 2023-07-31 16:02 o-Sakurajimamai-o 阅读(40) 评论(0) 推荐(0) 编辑
摘要:# 多层感知机 # 获取数据 import d2lzh from mxnet import autograd batch_size = 256 train_data, test_data = d2lzh.load_data_fashion_mnist(batch_size) # 读入数据 from 阅读全文 »
posted @ 2023-07-29 17:02 o-Sakurajimamai-o 阅读(16) 评论(0) 推荐(0) 编辑
摘要:# 模型选择 欠拟合与过拟合 # 创建数据集 from mxnet import autograd from mxnet import ndarray as nd from mxnet import gluon num_train = 100 num_tset = 100 true_w = [1.2 阅读全文 »
posted @ 2023-07-29 17:02 o-Sakurajimamai-o 阅读(15) 评论(0) 推荐(0) 编辑
摘要:# 多类->线性回归 from mxnet import gluon from mxnet import ndarray as nd import matplotlib.pyplot as plt def transform(data, label): return data.astype('flo 阅读全文 »
posted @ 2023-07-27 16:14 o-Sakurajimamai-o 阅读(33) 评论(0) 推荐(0) 编辑
摘要:# 数据结构,矩阵 # http://zh.gluon.ai/chapter_prerequisite/ndarray.html from mxnet import ndarray as nd print(nd.zeros((3, 4))) # 创建3x4的0矩阵 x = nd.ones((3, 4 阅读全文 »
posted @ 2023-07-26 13:23 o-Sakurajimamai-o 阅读(7) 评论(0) 推荐(0) 编辑
摘要:# 不需要定义变量 # # while循环: # while 条件 : # xxx # xxx # for 循环: # for 临时变量 in 范围容器(可用range,如果是容器的话,就是遍历,如果in 10,就是遍历0-10) # for循环的范围是大于等于第一个小于最后一个,也就是 int i 阅读全文 »
posted @ 2023-07-17 18:26 o-Sakurajimamai-o 阅读(16) 评论(0) 推荐(1) 编辑

-- --
点击右上角即可分享
微信分享提示