上一页 1 ··· 14 15 16 17 18
摘要: symbols = '$%^&*♕' codes = [] # 创建一个codes列表 for symbol in symbols: # 用for循环迭代symbols codes.append(ord(symbol)) # 将symbols中的元素迭代取出后转化为Unicode码并添加到列表中 c 阅读全文
posted @ 2021-09-08 10:34 里列昂遗失的记事本 阅读(62) 评论(0) 推荐(1)
摘要: PyTorch的配置 这里附上官网的链接https://pytorch.org/get-started/locally/ CPU版本 选择PyTorch版本(PyTorch Build),Stable(稳定版),Nightly(测试版) 系统版本,这里只介绍Windows系统的PyTorch环境配置 阅读全文
posted @ 2021-09-06 23:01 里列昂遗失的记事本 阅读(314) 评论(0) 推荐(0)
摘要: import torch from torchvision import transforms from torchvision import datasets from torch.utils.data import DataLoader import torch.nn.functional as 阅读全文
posted @ 2021-09-06 22:34 里列昂遗失的记事本 阅读(120) 评论(0) 推荐(0)
摘要: import torch # 引入模块PyTorch from torchvision import transforms # 从torch视觉中引入转换函数 from torchvision import datasets # 导入数据库 from torch.utils.data import 阅读全文
posted @ 2021-09-06 22:10 里列昂遗失的记事本 阅读(230) 评论(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 里列昂遗失的记事本 阅读(363) 评论(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 里列昂遗失的记事本 阅读(268) 评论(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 里列昂遗失的记事本 阅读(70) 评论(0) 推荐(0)
摘要: import collections # 引入collections模块 Card = collections.namedtuple('Card', ['rank', 'suit']) # 用namedtuple创造了一个简单的类Card class FrenchDeck: ranks = [str 阅读全文
posted @ 2021-09-05 20:24 里列昂遗失的记事本 阅读(101) 评论(0) 推荐(0)
摘要: 从零开始学Python 第一节课 学会了Python的变量赋值、运算符使用和强制类型转换 if __name__ == '__main__': print('Hello World') print('人因梦想而伟大') print('▁▄▇▇▄▁') print('人是唯一会交易的动物,因为没有狗会 阅读全文
posted @ 2021-09-04 20:18 里列昂遗失的记事本 阅读(100) 评论(0) 推荐(0)
摘要: 使用Python的print函数来输出植物大战僵尸中的石头怪 根据给出的图片用字符串来拼接植物大战僵尸中的石头怪 print(' ' * 2 + '* ' * 5 + '\n' + ' ' + '*' + ' ' * 10 + '*' + '\n' \ + '*' + ' ' * 4 + '@' + 阅读全文
posted @ 2021-09-04 20:05 里列昂遗失的记事本 阅读(187) 评论(0) 推荐(0)
上一页 1 ··· 14 15 16 17 18