随笔分类 - 实验
摘要:1 导入实验所需要的包 import torch import torch.nn as nn import torchvision import torchvision.transforms as transforms import torch.nn.functional as F from tor
阅读全文
摘要:1 导入包 import torch import torch.nn as nn import numpy as np import torchvision import torchvision.transforms as transforms import matplotlib.pyplot as
阅读全文
摘要:1 导入包 import torch import numpy as np import torch.nn as nn from torch.utils.data import TensorDataset,DataLoader import torchvision from IPython impo
阅读全文
摘要:1 导入实验需要的包 import torch import numpy as np from torch import nn from torchvision.datasets import MNIST import torchvision.transforms as transforms imp
阅读全文
摘要:1 导入包 import torch import torch.nn as nn from torch.utils.data import TensorDataset,DataLoader from torch.nn import init import torch.optim as optim f
阅读全文
摘要:1 导入实验需要的包 import torch from torch import nn import numpy as np import matplotlib.pyplot as plt from torch.utils.data import DataLoader,TensorDataset
阅读全文
摘要:1 导入实验需要的包 import numpy as np import torch from torch import nn from sklearn.model_selection import train_test_split import matplotlib.pyplot as plt f
阅读全文
摘要:1 导入实验需要的包 import torch import numpy as np import random from IPython import display import matplotlib.pyplot as plt from torch.utils.data import Data
阅读全文
摘要:1 导入所需要的包 import numpy as np import torch from torch import nn import matplotlib.pyplot as plt from IPython import display from torch.utils.data impor
阅读全文
摘要:1 导入numpy包 import numpy as np 2 sigmoid函数 def sigmoid(x): return 1/(1+np.exp(-x)) demox = np.array([1,2,3]) print(sigmoid(demox)) #报错 #demox = [1,2,3]
阅读全文
摘要:1 导入包 import numpy as np 2 初始化模型参数 ### 初始化模型参数 def initialize_params(dims): w = np.zeros((dims, 1)) b = 0 return w, b 3 损失函数计算 ### 包括线性回归公式、均方损失和参数偏导三
阅读全文
摘要:1 手写实现PCA import numpy as np class PCA(): # 计算协方差矩阵 def calc_cov(self, X): m = X.shape[0] # 数据标准化,X的每列减去列均值 X = (X - np.mean(X, axis=0)) return 1 / m
阅读全文
摘要:1 导入相关模块 import numpy as np from collections import Counter import matplotlib.pyplot as plt from sklearn import datasets from sklearn.utils import shu
阅读全文
摘要:1 导入实验需要的包 import torch import torch.nn as nn import torch.nn.functional import torch.optim as optim import torch.utils.data.dataloader as dataloader
阅读全文
摘要:参考文档 自编码器及相关变种算法简介 四种类型自编码器AutoEncoders理解及代码实现 堆栈自编码器 Part1 加载项目需要的包 import torch from torch import nn, optim, functional, utils import torchvision fr
阅读全文
摘要:#导入实验需要的包 import torch import torch.nn as nn import torch.utils.data as Data import torchvision import matplotlib.pyplot as plt from mpl_toolkits.mplo
阅读全文
摘要:1 import torch from torch import nn,optim from torch.autograd import Variable from torchvision import transforms,datasets from torch.utils.data import
阅读全文
摘要:计算过程参考:《机器学习——主成分分析(PCA)》 代码: X = np.array([[-1, -2], [-1, 0], [0, 0], [2, 1], [0, 1]]) print(X) def PCA(X,n): #转置 X = np.transpose(X) #求特征的均值 X_mean
阅读全文
摘要:1 导入实验所需要的包 import torch import torch.nn as nn import numpy as np import torchvision import torchvision.transforms as transforms import matplotlib.pyp
阅读全文
摘要:1 导入实验所需要的包 import torch import torch.nn as nn import numpy as np import torchvision import torchvision.transforms as transforms import matplotlib.pyp
阅读全文