随笔分类 - ML_Code
摘要:点乘 torch.mul(a,b)二维矩阵乘 torch.mm(a,b)三维矩阵乘 torch.bmm(a,b)高维矩阵乘 torch.matmul(a,b) https://blog.csdn.net/sunjinshengli/article/details/121901225
阅读全文
摘要: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
阅读全文