上一页 1 ··· 14 15 16 17 18
摘要: import torch # 引入模块PyTorch from torchvision import transforms # 从torch视觉中引入转换函数 from torchvision import datasets # 导入数据库 from torch.utils.data import 阅读全文
posted @ 2021-09-06 22:10 里列昂遗失的记事本 阅读(182) 评论(0) 推荐(0) 编辑
摘要: import torch import torch.nn.functional as F # 从torch引入激活函数 x_data = torch.tensor([[1.0], [2.0], [3.0]]).cuda() # 将数据放在GPU上 y_data = torch.tensor([[0. 阅读全文
posted @ 2021-09-06 21:39 里列昂遗失的记事本 阅读(326) 评论(0) 推荐(0) 编辑
摘要: 这里选择将模型和loss还有数据都在GPU上,方便后续能够将大型神经网络的计算图放在GPU上来加快训练速度 import torch # 引入PyTorch模块 x = torch.tensor([[1.0], [2.0], [3.0]]).cuda() # 创建张量x,y并使用cuda()将数据存 阅读全文
posted @ 2021-09-06 17:34 里列昂遗失的记事本 阅读(231) 评论(0) 推荐(0) 编辑
摘要: 利用特殊方法,来使得自定义对象来实现一个二维向量(Vector)类 一个简单的二维向量类 from math import hypot class Vector: def __init__(self, x=0, y=0): self.x = x # 将输入的x,y分别赋值给类属性x,y self.y 阅读全文
posted @ 2021-09-06 16:57 里列昂遗失的记事本 阅读(54) 评论(0) 推荐(0) 编辑
摘要: import collections # 引入collections模块 Card = collections.namedtuple('Card', ['rank', 'suit']) # 用namedtuple创造了一个简单的类Card class FrenchDeck: ranks = [str 阅读全文
posted @ 2021-09-05 20:24 里列昂遗失的记事本 阅读(74) 评论(0) 推荐(0) 编辑
摘要: 从零开始学Python 第一节课 学会了Python的变量赋值、运算符使用和强制类型转换 if __name__ == '__main__': print('Hello World') print('人因梦想而伟大') print('▁▄▇▇▄▁') print('人是唯一会交易的动物,因为没有狗会 阅读全文
posted @ 2021-09-04 20:18 里列昂遗失的记事本 阅读(80) 评论(0) 推荐(0) 编辑
摘要: 使用Python的print函数来输出植物大战僵尸中的石头怪 根据给出的图片用字符串来拼接植物大战僵尸中的石头怪 print(' ' * 2 + '* ' * 5 + '\n' + ' ' + '*' + ' ' * 10 + '*' + '\n' \ + '*' + ' ' * 4 + '@' + 阅读全文
posted @ 2021-09-04 20:05 里列昂遗失的记事本 阅读(147) 评论(0) 推荐(0) 编辑
上一页 1 ··· 14 15 16 17 18