摘要: 出错代码: 点击查看代码 dataset_numpy = x[0].cpu().numpy() centers = centers.cpu().numpy() codes = codes.cpu().numpy() 修改后代码: 点击查看代码 dataset_numpy = x[0].cpu().d 阅读全文
posted @ 2022-11-23 13:28 荒北 阅读(1246) 评论(0) 推荐(0) 编辑
摘要: k均值(k-means) 无监督 学习向量量化(learning vector quantization) 有监督 高斯混合(mixture of gaussian) 概率 阅读全文
posted @ 2022-10-11 16:02 荒北 阅读(11) 评论(0) 推荐(0) 编辑
摘要: sudo apt update apt-cache depends build-essential sudo apt install build-essential gcc -v g++ -v 参考 Ubuntu - 安装gcc 阅读全文
posted @ 2022-09-17 20:24 荒北 阅读(616) 评论(0) 推荐(0) 编辑
摘要: 点击查看代码 import torch from torch import nn from d2l import torch as d2l net = nn.Sequential( nn.Conv2d(1, 6, kernel_size=5, padding=2), nn.Sigmoid(), nn 阅读全文
posted @ 2022-08-17 23:01 荒北 阅读(31) 评论(0) 推荐(0) 编辑
摘要: 点击查看代码 import torch from torch import nn from d2l import torch as d2l # 输出为输入中每个区域的最大值或平均值 def pool2d(X, pool_size, mode='max'): p_h, p_w = pool_size 阅读全文
posted @ 2022-08-17 23:00 荒北 阅读(19) 评论(0) 推荐(0) 编辑
摘要: 点击查看代码 import torch from d2l import torch as d2l def corr2d_multi_in(X, K): # 先遍历“X”和“K”的第0个维度(通道维度),再把它们加在一起 # print('K.shape = ', K.shape) return su 阅读全文
posted @ 2022-08-17 22:56 荒北 阅读(25) 评论(0) 推荐(0) 编辑
摘要: 点击查看代码 import torch from torch import nn # 此函数初始化卷积层权重,并对输入和输出提高和缩减相应的维数 def comp_conv2d(conv2d, X): # 这里的(1,1)表示批量大小和通道数都是1 X = X.reshape((1, 1) + X. 阅读全文
posted @ 2022-08-17 22:55 荒北 阅读(11) 评论(0) 推荐(0) 编辑
摘要: 点击查看代码 import torch from torch import nn from d2l import torch as d2l def corr2d(X, K): #@save """计算二维互相关运算""" h, w = K.shape Y = torch.zeros((X.shape 阅读全文
posted @ 2022-08-17 22:54 荒北 阅读(13) 评论(0) 推荐(0) 编辑
摘要: 点击查看代码 import json import multiprocessing import os import torch from torch import nn from d2l import torch as d2l d2l.DATA_HUB['bert.base'] = (d2l.DA 阅读全文
posted @ 2022-08-17 22:52 荒北 阅读(24) 评论(0) 推荐(0) 编辑
摘要: 点击查看代码 import os import re import torch from torch import nn from d2l import torch as d2l #@save d2l.DATA_HUB['SNLI'] = ( 'https://nlp.stanford.edu/pr 阅读全文
posted @ 2022-08-17 22:51 荒北 阅读(21) 评论(0) 推荐(0) 编辑