摘要: 简单实现了torch版本的变分自编码器 参考大佬TensorFlow版本的VAE:膜拜大佬 import os import numpy as np from PIL import Image from matplotlib import pyplot as plt import torch fro 阅读全文
posted @ 2022-12-06 16:41 麦扣 阅读(229) 评论(0) 推荐(0) 编辑
摘要: 1. jupyter from time import sleep from tqdm.notebook import tqdm for epoch in range(1, CFG.epoch + 1): loop = tqdm((train_loader), total = len(train_l 阅读全文
posted @ 2022-12-06 15:37 麦扣 阅读(193) 评论(0) 推荐(0) 编辑
摘要: import torch import torch.nn as nn from torch.utils.data import DataLoader, Dataset import numpy as np from tqdm import tqdm sentences = ["jack like d 阅读全文
posted @ 2022-08-24 17:27 麦扣 阅读(37) 评论(0) 推荐(0) 编辑
摘要: x = torch.rand(16, 3) y = torch.LongTensor([0 for x in range(16)])# 类别的样本比例为X,alpha为1-X,样本量越多受到的重视应该越小 alpha = torch.tensor([[0.43],[0.75],[0.82]]) cl 阅读全文
posted @ 2022-07-28 19:31 麦扣 阅读(1481) 评论(0) 推荐(0) 编辑
摘要: import torch import torch.nn as nn from typing import List, Optional class CRF(nn.Module): """Conditional random field. This module implements a condi 阅读全文
posted @ 2022-07-23 19:13 麦扣 阅读(152) 评论(0) 推荐(0) 编辑
摘要: 1. 使用MovieLens数据集搭建了一个简易torch版本的NCF模型,采用了1:1的负采样,跑10个epoch二分类准确率达到0.8左右,代码贴上: import pandas as pd import numpy as np from sklearn.model_selection impo 阅读全文
posted @ 2022-07-13 19:33 麦扣 阅读(477) 评论(0) 推荐(0) 编辑
摘要: 在cbow方法中,是用周围词预测中心词,从而利用中心词的预测结果情况,使用GradientDesent方法,不断的去调整周围词的向量。当训练完成之后,每个词都会作为中心词,把周围词的词向量进行了调整,这样也就获得了整个文本里面所有词的词向量。要注意的是, cbow的对周围词的调整是统一的:求出的gr 阅读全文
posted @ 2022-02-22 15:01 麦扣 阅读(324) 评论(0) 推荐(0) 编辑
摘要: 特征工程中经常对数值型特征进行归一化来解决特征取值范围不统一的问题,但无法改变特征值的分布。 比如说对于电影的评分,由于人们打分有“中庸偏上“的倾向,因此评分大量集中在一个数值的附近,这样模型因为样本大量集中在一个区间,所以特征的区分度不高(都在一个值附近),模型的效果不好。 所以设置分割区间进行分 阅读全文
posted @ 2022-02-21 15:45 麦扣 阅读(295) 评论(0) 推荐(0) 编辑
摘要: from matplotlib import ticker plt.plot(train['first_active_month'].value_counts().sort_index()) # 参数为间隔数量 plt.gca().xaxis.set_major_locator(ticker.Mul 阅读全文
posted @ 2021-12-31 10:28 麦扣 阅读(1785) 评论(0) 推荐(0) 编辑
摘要: function ConnectButton(){ console.log("Connect pushed"); document.querySelector("#top-toolbar > colab-connect-button").shadowRoot.querySelector("#conn 阅读全文
posted @ 2021-11-15 16:40 麦扣 阅读(88) 评论(0) 推荐(0) 编辑