nn
This commit is contained in:
parent
bc53a89c11
commit
6c18c617c3
5 changed files with 95 additions and 1 deletions
|
|
@ -36,3 +36,4 @@ vGPU \footnote{https://docs.nvidia.com/grid/5.0/grid-vgpu-user-guide/index.html}
|
|||
|
||||
|
||||
\section{Cloud computing}
|
||||
|
||||
|
|
|
|||
35
doc/tuitorialnotes.tex
Normal file
35
doc/tuitorialnotes.tex
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
notes from tuitorial
|
||||
|
||||
auto regresive
|
||||
|
||||
feed forward cannot learn from the past
|
||||
recurrent neuron network can learn from the past
|
||||
xt -> yt
|
||||
|
||||
unrolling through time
|
||||
|
||||
|
||||
Y = activation (Wx +b)
|
||||
|
||||
|
||||
Stored state - memory
|
||||
internal state html
|
||||
each neoron has two weight
|
||||
|
||||
|
||||
basic cell, LSTM cell , GRU cell
|
||||
|
||||
Gradient decent
|
||||
|
||||
back propogation through time
|
||||
|
||||
Long Short Term Memory
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
confusion matrix
|
||||
logsoftmax
|
||||
|
||||
https://stanford.edu/~shervine/teaching/cs-230/cheatsheet-recurrent-neural-networks
|
||||
48
rm_clasificationmodel/NN.py
Normal file
48
rm_clasificationmodel/NN.py
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
import torch
|
||||
import torch.nn as nn
|
||||
import torch.nn.functional as F
|
||||
|
||||
class RNN(nn.Module):
|
||||
|
||||
def __init__(self, input_size, hidden_size, output_size):
|
||||
|
||||
super(RNN, self).__init__()
|
||||
|
||||
self.hidden_size = hidden_size
|
||||
|
||||
self.i2h = nn.Linear(input_size + hidden_size, hidden_size)
|
||||
|
||||
self.i2o = nn.Linear(input_size + hidden_size, output_size)
|
||||
|
||||
self.softmax = nn.LogSoftmax(dim=1)
|
||||
|
||||
def forward(self, input, hidden):
|
||||
combined = torch.cat((input, hidden), 1)
|
||||
|
||||
hidden = self.i2h(combined)
|
||||
|
||||
output = self.i2o(combined)
|
||||
output = self.softmax(output)
|
||||
|
||||
return output, hidden
|
||||
|
||||
def initHidden(self):
|
||||
return torch.zeros(1, self.hidden_size)
|
||||
|
||||
|
||||
|
||||
|
||||
class Net(nn.Module):
|
||||
|
||||
def __init__(self,input_size,hidden_size,output_size):
|
||||
super(Net, self).__init__()
|
||||
self.fc1 = nn.Linear(input_size, hidden_size)
|
||||
self.fc2 = nn.Linear(hidden_size, hidden_size)
|
||||
self.fc3 = nn.Linear(hidden_size, output_size)
|
||||
|
||||
def forward(self, x):
|
||||
x = F.sigmoid(self.fc1(x))
|
||||
x = F.sigmoid(self.fc2(x))
|
||||
x = self.fc3(x)
|
||||
|
||||
return F.log_softmax(x, dim=-1)
|
||||
10
rm_clasificationmodel/VectorizeClass.py
Normal file
10
rm_clasificationmodel/VectorizeClass.py
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
from sklearn.feature_extraction.text import CountVectorizer
|
||||
class Vectorize():
|
||||
def __init__(self,ngram_min,ngram_max):
|
||||
self.n_gram_vectorizer = CountVectorizer(ngram_range=(ngram_min, ngram_max))
|
||||
|
||||
def ngramFit(self,doc):
|
||||
self.n_gram_vectorizer.fit(doc)
|
||||
|
||||
def transform (self,doc):
|
||||
self.n_gram_vectorizer.transform(doc)
|
||||
Loading…
Reference in a new issue