From 6c18c617c3648c371f7ea59562195704e08758ba Mon Sep 17 00:00:00 2001 From: shoney Date: Sun, 25 Jun 2023 23:50:06 +0000 Subject: [PATCH] nn --- doc/chapters/chapter5.tex | 3 +- doc/tuitorialnotes.tex | 35 ++++++++++++++++++ fetchDatafromDb/vectorization.ipynb | 0 rm_clasificationmodel/NN.py | 48 +++++++++++++++++++++++++ rm_clasificationmodel/VectorizeClass.py | 10 ++++++ 5 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 doc/tuitorialnotes.tex delete mode 100644 fetchDatafromDb/vectorization.ipynb create mode 100644 rm_clasificationmodel/NN.py create mode 100644 rm_clasificationmodel/VectorizeClass.py diff --git a/doc/chapters/chapter5.tex b/doc/chapters/chapter5.tex index ee29b78..34e10f3 100644 --- a/doc/chapters/chapter5.tex +++ b/doc/chapters/chapter5.tex @@ -35,4 +35,5 @@ vGPU \footnote{https://docs.nvidia.com/grid/5.0/grid-vgpu-user-guide/index.html} \subsection{SSH} -\section{Cloud computing} \ No newline at end of file +\section{Cloud computing} + diff --git a/doc/tuitorialnotes.tex b/doc/tuitorialnotes.tex new file mode 100644 index 0000000..a64a624 --- /dev/null +++ b/doc/tuitorialnotes.tex @@ -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 \ No newline at end of file diff --git a/fetchDatafromDb/vectorization.ipynb b/fetchDatafromDb/vectorization.ipynb deleted file mode 100644 index e69de29..0000000 diff --git a/rm_clasificationmodel/NN.py b/rm_clasificationmodel/NN.py new file mode 100644 index 0000000..8e59e5a --- /dev/null +++ b/rm_clasificationmodel/NN.py @@ -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) \ No newline at end of file diff --git a/rm_clasificationmodel/VectorizeClass.py b/rm_clasificationmodel/VectorizeClass.py new file mode 100644 index 0000000..6b6993a --- /dev/null +++ b/rm_clasificationmodel/VectorizeClass.py @@ -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)