摘要: 3.2.0 头文件 import random import torch from d2l import torch as d2l 3.2.1 关于yield关键字 # 关于yield关键字 def foo(): print("starting...") while True: res = yiel 阅读全文
posted @ 2022-11-01 21:45 yc-limitless 阅读(48) 评论(0) 推荐(0) 编辑
摘要: import math import time import numpy as np import torch from d2l import torch as d2l class Timer: #@save """记录多次运行时间""" def __init__(self): self.times 阅读全文
posted @ 2022-11-01 15:38 yc-limitless 阅读(23) 评论(0) 推荐(0) 编辑
摘要: 2.4.1 计算梯度 import torch x=torch.arange(4.0,requires_grad=True) print(x) # 输出: # tensor([0., 1., 2., 3.], requires_grad=True) y = 2 * torch.dot(x, x) p 阅读全文
posted @ 2022-11-01 15:14 yc-limitless 阅读(17) 评论(0) 推荐(0) 编辑
摘要: 2.3.1 头文件 import torch 2.3.2 标量张量的计算 # 定义两个标量 x = torch.tensor(3.0) y = torch.tensor(2.0) # 加法 print(x + y) # 输出: # tensor(5.) # 减法 print(x - y) # 输出: 阅读全文
posted @ 2022-11-01 14:34 yc-limitless 阅读(35) 评论(0) 推荐(0) 编辑
摘要: 2.2.0 头文件 import os import pandas as pd import torch 2.2.1 读取数据集 # 下面一段代码的作用是创建一个人工数据集,并存储在CSV文件中 # 在上一级目录下创建一个data文件夹,exist_ok为false表示如果该文件夹已经存在就报错,为 阅读全文
posted @ 2022-11-01 11:07 yc-limitless 阅读(143) 评论(0) 推荐(0) 编辑
摘要: 2.0 头文件 import torch 2.1 创建张量 # 创建一个一维包含12个元素,元素值为0~11的张量 x = torch.arange(12) print(x) # 输出: # tensor([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) # 查看张量 阅读全文
posted @ 2022-11-01 10:04 yc-limitless 阅读(33) 评论(0) 推荐(0) 编辑
摘要: 问题出现原因: 我的笔记本倾斜放置就会导致WLAN标志消失 解决方案一: 将笔记本水平放置后,长按开机键40秒。如果一次不行,就重复该方法多次。(WLAN出现后,如果电脑出现倾斜的情况,WLAN还会再次消失,不推荐)。 解决方案二: 购买外接网卡,价格为30元左右,一卡解君忧。(倾斜电脑,WLAN不 阅读全文
posted @ 2022-11-01 08:56 yc-limitless 阅读(1055) 评论(0) 推荐(0) 编辑
摘要: nvidia-smi命令用来查看GPU利用率和显存占用情况。 在命令行直接输入 nvidia-smi 命令,得到如下界面: 界面介绍如下所示: 具体参考自如下博客: https://blog.csdn.net/weixin_44966641/article/details/121228579 阅读全文
posted @ 2022-11-01 08:39 yc-limitless 阅读(2656) 评论(0) 推荐(0) 编辑