/images/avatar.png

vllbc

OOV问题

面试中经常被问到的一个问题就是out of vocabulary,可能是因为当前数据集中出现了提前准备好的单词表中没有的word,也可能是因为te

regression

一个线性回归的神经网络模型 import torch import numpy as np import pandas as pd import plotly.graph_objects as go import torch.nn import torch.nn.functional as F from torch.autograd import Variable x = torch.unsqueeze(torch.linspace(-10,10,100),dim=1) y = x*2+10+torch.rand(x.size()) # scatter = go.Scatter(x = torch.squeeze(x),y = torch.squeeze(y),mode = 'markers') # fig = go.Figure(scatter) # fig.show() class Net(torch.nn.Module): def __init__(self): super(Net,self).__init__() self.hidden = torch.nn.Linear(1,10) self.linser = torch.nn.Linear(10,1)

bincount

很简单,就是统计x中的数出现次数,返回结果的最大长度就是x中的最大值+1,idx为对应的数,值为出现的次数,没有出现的为0。 x = np.array([7, 6, 2, 1, 4]) #