- 博客(8)
- 收藏
- 关注
原创 gan生成对抗网络代码——人工智能第七次作业
G_ideas = torch.randn(BATCH_SIZE, N_IDEAS, requires_grad=True) # 随机想法\n。prob_artist1 = D(G_paintings.detach()) # D 尝试减少此概率。D_loss.backward(retain_graph=True) # 重用计算图。prob_artist1 = D(G_paintings) # D 尝试减少此概率。G_paintings = G(G_ideas) # 来自G的假画(随机想法)
2023-04-20 21:46:27
72
原创 人工智能第六次作业——自编码/非监督学习
transform=torchvision.transforms.ToTensor(), # 将 pil 映像或 Numpy ndarray 转换为。nn.Linear(12, 3), # 压缩为 3 个特征,可在plt中可视化。nn.Sigmoid(), # 压缩到范围(0,1)# 数据加载器用于在训练中轻松返回小批量,图像批处理形状将为(50,1,28,28)# torch.manual_seed(1) # 重现。plt.ion() # 连续绘制。
2023-04-16 12:57:47
84
原创 pytorch保存提取
torch.save(net1.state_dict(), 'D:/file1/net_params.pkl') # 只保存网络中的参数 (速度快, 占内存少)torch.save(net1.state_dict(), 'net_params.pkl') # 只保存网络中的参数 (速度快, 占内存少)torch.save(net1, 'D:/file1/net.pkl') # 保存整个网络。torch.save(net1, 'net.pkl') # 保存整个网络。
2023-04-05 22:22:32
117
原创 CNN卷积神经网络实现
nn.MaxPool2d(kernel_size=2), # 在 2x2 空间里向下采样, output shape (16, 14, 14)x = x.view(x.size(0), -1) # 展平多维的卷积图成 (batch_size, 32 * 7 * 7)download=DOWNLOAD_MNIST, # 没下载就下载, 下载了就不用再下了。# 批训练 50samples, 1 channel, 28x28 (50, 1, 28, 28)# Mnist 手写数字。
2023-03-27 21:34:10
95
原创 pytorch实现三分类模型
x1 = torch.normal(-2*n_data, 1) # 类型1 x data (tensor), shape=(100, 1)x1 = torch.normal(-2*n_data, 1) # 类型1 x data (tensor), shape=(100, 1)x1 = torch.normal(-2*n_data, 1) # 类型1 x data (tensor), shape=(100, 1)
2023-03-26 17:17:44
240
原创 pytorch中自定义net实现回归算法 人工智能概论第二次作业
plot and show learning process 每学习五步打印一次。plt.ion() # something about plotting 添加可视化。回归是机器学习三大基本模型中很重要的一环,其功能是建模和分析变量之间的关系。截图为修改了xy定义以及学习率之后的结果。
2023-03-19 13:36:45
159
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人