doc
This commit is contained in:
parent
0b11ddf99b
commit
e9511ad649
11 changed files with 221 additions and 88 deletions
|
|
@ -374,8 +374,8 @@ How triangular learning rate works?
|
|||
|
||||
\begin{enumerate}
|
||||
\item \textbf{Initialize}: The step size $ t $, minimum bound or base learning rate $ base\_lr$ and maximum bound or the max learning rate $max\_lr$ are initialized. These hyperparameters are tuned based on the architecture of the model. In this experiment, the values set are $ base\_lr=0.0075 ; max\_lr=0.02; t=10000$.
|
||||
\item \textbf{Up}: During training, the learning rate is linearly increased from $ base\_lr$ to $max\_lr$ over a certain number of step size $ t $.
|
||||
\item \textbf{Down}: During training, the learning rate is linearly decreased from $max\_lr$ to $base\_lr$.
|
||||
\item \textbf{Up phase}: During training, the learning rate is linearly increased from $ base\_lr$ to $max\_lr$ over a certain number of step size $ t $.
|
||||
\item \textbf{Down phase}: During training, the learning rate is linearly decreased from $max\_lr$ to $base\_lr$.
|
||||
\end{enumerate}
|
||||
|
||||
\begin{figure}[H]
|
||||
|
|
@ -385,4 +385,84 @@ How triangular learning rate works?
|
|||
}
|
||||
\label{fig:trl}
|
||||
\end{figure}
|
||||
In figure \ref{fig:trl}, the blue lines represent learning rate values changing between the bounds. The input parameter stepsize is the number of iterations in half a cycle \parencite{Smith.03062015}.
|
||||
Figure \ref{fig:trl} is pictorial representation of triangular learning rate. The blue lines represent learning rate values changing between the bounds. The input parameter step-size is the number of iterations in half a cycle \parencite{Smith.03062015}.
|
||||
|
||||
\begin{lstlisting}[language=Python,label={code:triangularLR}, caption={Triangular learning rate}]
|
||||
def runBatchWithTLR(self):
|
||||
# each unit is half cycle iteration
|
||||
batch=[10000,10000,10000,10000,10000,10000,10000,10000,10000,10000]
|
||||
start = time.time()
|
||||
no_batch=0
|
||||
no_iterations=0
|
||||
learning_rates =[]
|
||||
|
||||
for n_iters in batch:
|
||||
|
||||
no_batch =no_batch+1
|
||||
rem=no_batch % 2
|
||||
# linearly space the learning rate by number of iterations using np.linspace
|
||||
learn_rates=np.linspace(self.lr_low,self.lr_max,n_iters)
|
||||
# for even number of batch flip the array for down phase
|
||||
if rem==0:
|
||||
learn_rates=np.flip(learn_rates)
|
||||
|
||||
# run the iterations along with the linearly spaced learning rate.
|
||||
for epoch,lr in zip(range(1, n_iters + 1),learn_rates):
|
||||
no_iterations= no_iterations+1
|
||||
|
||||
self.learning_rate=lr
|
||||
category, name, category_tensor, name_tensor = self.data.randomTrainingExample()
|
||||
|
||||
output, loss = self.train(category_tensor, name_tensor)
|
||||
self.current_loss += loss
|
||||
# Print ``iter`` number, loss, name and guess
|
||||
if epoch % 5000 == 0:
|
||||
guess, guess_i = self.data.categoryFromOutput(output)
|
||||
correct = 'yes' if guess == category else 'no (%s)' % category
|
||||
|
||||
print('%d %d%% (%s) %.4f %s / %s %s %.10f' % (no_iterations,
|
||||
no_iterations / np.sum(batch) * 100,
|
||||
self.helper.timeSince(start),
|
||||
loss,
|
||||
name,
|
||||
guess,
|
||||
correct, self.learning_rate))
|
||||
|
||||
|
||||
if epoch % 5000 == 0:
|
||||
if (math.isnan(self.current_loss)!=True):
|
||||
self.all_losses.append(self.current_loss / 5000)
|
||||
learning_rates.append(self.learning_rate)
|
||||
self.current_loss = 0
|
||||
else:
|
||||
break
|
||||
\end{lstlisting}
|
||||
|
||||
Listing \ref{code:triangularLR} is the code to train the model using triangular learning rate. Below is the explanation of the code.
|
||||
|
||||
\begin{enumerate}
|
||||
\item \textbf{Variable initialization}:
|
||||
\begin{itemize}
|
||||
\item \textbf{batch}: \\ A list of elements representing number of iterations in a batch. Each batch represents half cycle or step-size.
|
||||
\item \textbf{start = time.time()} :\\ This stores current time at the beginning of the training process.
|
||||
\end{itemize}
|
||||
\item Batch iteration: \\
|
||||
\begin{itemize}
|
||||
\item \textbf{rem = no\_batch \% 2}: \\ Calculates reminder of no\_batch. It determines whether to flip the learning rates array. If rem is 0 (indicating an even batch number), the array is fliped using numpy's \parencite{harris2020array} \textit{np.flip} method.
|
||||
\item learn\_rates :\\ This stores linearly spaced learning rates between $base\_lr$ and $max\_lr$ divided into batch size.
|
||||
\end{itemize}
|
||||
|
||||
|
||||
\end{enumerate}
|
||||
|
||||
|
||||
\subsection{Experimentation and analysis}
|
||||
In this experiment, the model is trained with and without triangular learning rate method. The total number of iterations is $10000 \times 10$. The graph of Loss Vs Learning rate and time taken to complete the iterations illustrates the performance of the model. The graph plotted for each $2500$ iterations provide insight on how the model is performing. The lesser the time taken
|
||||
\begin{enumerate}
|
||||
\item Triangular learning rate; where $base\_lr =0.0075$ and $max\_lr=0.02$: \\
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
\end{enumerate}
|
||||
|
|
|
|||
|
|
@ -1 +1,4 @@
|
|||
\chapter*{Introduction}
|
||||
\chapter{Introduction}
|
||||
|
||||
\section{Topic overview}
|
||||
|
||||
|
|
|
|||
BIN
doc/images/SRH_Hochschule_Heidelberg_logo.svg.png
Normal file
BIN
doc/images/SRH_Hochschule_Heidelberg_logo.svg.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 24 KiB |
|
|
@ -0,0 +1,4 @@
|
|||
[ZoneTransfer]
|
||||
ZoneId=3
|
||||
ReferrerUrl=https://de.wikipedia.org/
|
||||
HostUrl=https://upload.wikimedia.org/wikipedia/commons/thumb/3/34/SRH_Hochschule_Heidelberg_logo.svg/800px-SRH_Hochschule_Heidelberg_logo.svg.png
|
||||
|
|
@ -61,11 +61,11 @@
|
|||
\graphicspath{ {images/} }
|
||||
\addbibresource{References.bib}
|
||||
|
||||
\includeonly{preliminary/title,%
|
||||
preliminary/dedication,%
|
||||
preliminary/abstract,%
|
||||
preliminary/acronyms,%
|
||||
chapters/introduction,%
|
||||
\includeonly{preliminary/title, %
|
||||
preliminary/affidavit, %
|
||||
preliminary/abstract, %
|
||||
preliminary/acronyms, %
|
||||
chapters/introduction, %
|
||||
chapters/chapter1,%
|
||||
chapters/chapter2,%
|
||||
chapters/chapter3,%
|
||||
|
|
@ -84,25 +84,17 @@ chapters/chapter7
|
|||
|
||||
%--------------------------------------------
|
||||
\include{preliminary/title.tex}
|
||||
% \include{preliminary/copyright.tex}
|
||||
\include{preliminary/dedication.tex}
|
||||
% \include{preliminary/approval-sheet.tex}
|
||||
% \include{preliminary/certificate.tex}
|
||||
% \include{preliminary/acknowledgement.tex}
|
||||
|
||||
\include{preliminary/dedication.tex}
|
||||
\include{preliminary/affidavit.tex}
|
||||
\include{preliminary/abstract.tex}
|
||||
|
||||
|
||||
\pagestyle{mypagestyle}
|
||||
|
||||
|
||||
\tableofcontents
|
||||
\listoffigures
|
||||
\listoftables
|
||||
\lstlistoflistings
|
||||
\include{preliminary/acronyms}
|
||||
|
||||
|
||||
%----------------- chapters --------------------
|
||||
\pagestyle{mypagestyle}
|
||||
\pagenumbering{arabic}
|
||||
|
||||
%---------------------------------------
|
||||
|
|
@ -115,6 +107,15 @@ chapters/chapter7
|
|||
\include{chapters/chapter6}
|
||||
\include{chapters/chapter7}
|
||||
|
||||
|
||||
|
||||
\pagenumbering{roman}
|
||||
\pagestyle{mypagestyle}
|
||||
|
||||
\listoffigures
|
||||
\listoftables
|
||||
\lstlistoflistings
|
||||
\include{preliminary/acronyms}
|
||||
\appendix
|
||||
% \include{chapters/appendix.tex}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,2 +1,20 @@
|
|||
\chapter*{Abstract}
|
||||
An abstract is a concise summary of a research paper or entire thesis. It is an original work, not an excerpted passage. An abstract must be fully self-contained and make sense by itself, without further reference to outside sources or to the actual paper.
|
||||
|
||||
\begin{center}
|
||||
Shoney Arickathil, School of Informatics, SRH Hochschule Heidelberg \\
|
||||
|
||||
Master Thesis \\
|
||||
\textbf{Application of Natural language processing in ECommerce}
|
||||
|
||||
\end{center}
|
||||
|
||||
|
||||
Electronic commerce started in early 1990's in which the business transactions are conducted through computer networks. The ease of buying a product online has reduced physical work and time required for decision-making by compare the product features. A wide range of products are sold online. One of the challenge is to well define a products' taxonomy. A product taxonomy is a hierarchical structure to organize the products in an E-commerce platform in such a way that customers can find the product in the fewest possible clicks.
|
||||
Product taxonomy for the same product may differ based on the supplier and manufacturer (sources). Hence, product taxonomy details cannot be imported directly from the sources into the E-commerce platform. Product details cannot be live until its taxonomy is not well-defined, this delays the time of product availability for customers. \\
|
||||
|
||||
In this thesis the author developed a machine learning classification model to predict the product taxonomy based on the features of the product. This is achieved with machine learning model. Experimenting and analyzing by varying model's parameters facilitated to determine models performance. \\
|
||||
|
||||
Initially, from the existing product taxonomy the features such as name and description were extracted. These extracted features were passed through process of text normalization, imputation of missing text to standardize it before converting it into One-Hot encoded format. These features and its lowest hierarchical level of category were processed by \acf*{RNN} machine learning model to learn the patterns of feature and classify it with the concept of probability distribution.\\
|
||||
|
||||
The result of predicting the lowest hierarchical level of product category based only on product name formed a foundation to create a machine learning model to predict the complete product taxonomy. As the level of category to be predicted increases the model's weight and product features need to be adjusted.
|
||||
|
||||
|
|
|
|||
17
doc/preliminary/affidavit.tex
Normal file
17
doc/preliminary/affidavit.tex
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
|
||||
{\Large Affidavit}
|
||||
\vspace*{0.5\baselineskip}
|
||||
|
||||
{\Large Here with I declare:}
|
||||
|
||||
\begin{itemize}
|
||||
\item that I have independently composed the chapters of the master thesis for which I am named as the author.
|
||||
\item that I did not use any other sources and additives but the once specified.
|
||||
\item that I did not submit this work for any other examination procedure.
|
||||
\end{itemize}
|
||||
|
||||
|
||||
\vspace*{5\baselineskip}
|
||||
|
||||
|
||||
Heidelberg, \today \hspace*{1mm} \hrulefill
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
\chapter*{}
|
||||
|
||||
\begin{center}
|
||||
\vfill
|
||||
{\itshape Dedicated to my \ldots.}
|
||||
\vfill
|
||||
\end{center}
|
||||
|
|
@ -1,25 +1,31 @@
|
|||
\begin{titlepage}
|
||||
|
||||
\begin{figure}[H]
|
||||
|
||||
\includegraphics[scale=0.5]{SRH_Hochschule_Heidelberg_logo.svg.png}
|
||||
|
||||
\end{figure}
|
||||
|
||||
\centering
|
||||
|
||||
|
||||
|
||||
{\Large \bfseries Application of Natural language processing in ECommerce}
|
||||
\vspace*{3\baselineskip}
|
||||
|
||||
{\Large Thesis}
|
||||
\vspace*{3\baselineskip}
|
||||
|
||||
{\Large Submitted in partial fulfillment of }
|
||||
\vspace*{0.5\baselineskip}
|
||||
|
||||
{\Large the requirements of the degree of }
|
||||
\vspace*{3.5\baselineskip}
|
||||
{\Large Master Thesis}
|
||||
\vspace*{1\baselineskip}
|
||||
|
||||
{\Large by }
|
||||
\vspace*{2\baselineskip}
|
||||
|
||||
{\Large \bfseries Shoney Arickathil }
|
||||
\vspace*{0.5\baselineskip}
|
||||
|
||||
{\Large \bfseries Arickathil,Shoney }
|
||||
\vspace*{0.5\baselineskip}
|
||||
{\Large Student no: 11017678 }
|
||||
\vspace*{2\baselineskip}
|
||||
|
||||
{\Large Supervisor: \bfseries Prof. Gerd Moekel }
|
||||
{\Large \today}
|
||||
\vspace*{3\baselineskip}
|
||||
|
||||
% \includegraphics[width=0.35\linewidth]{srhlogo}
|
||||
|
|
@ -27,9 +33,11 @@
|
|||
{\Large Masters in Applied Computer Science }
|
||||
\vspace*{0.5\baselineskip}
|
||||
|
||||
{\Large SRH Hochschule Heidelberg }
|
||||
{\Large SRH University Heidelberg \\ School of Informatics}
|
||||
\vspace*{3\baselineskip}
|
||||
|
||||
{\Large \today}
|
||||
|
||||
|
||||
|
||||
|
||||
\end{titlepage}
|
||||
BIN
lossinfo.png
BIN
lossinfo.png
Binary file not shown.
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 40 KiB |
|
|
@ -141,6 +141,7 @@ class Train():
|
|||
no_batch=0
|
||||
no_iterations=0
|
||||
learning_rates =[]
|
||||
times =[]
|
||||
|
||||
for n_iters in batch:
|
||||
|
||||
|
|
@ -159,7 +160,7 @@ class Train():
|
|||
output, loss = self.train(category_tensor, name_tensor)
|
||||
self.current_loss += loss
|
||||
# Print ``iter`` number, loss, name and guess
|
||||
if epoch % 5000 == 0:
|
||||
if epoch % 2500 == 0:
|
||||
guess, guess_i = self.data.categoryFromOutput(output)
|
||||
correct = '✓' if guess == category else '✗ (%s)' % category
|
||||
|
||||
|
|
@ -172,20 +173,28 @@ class Train():
|
|||
correct, self.learning_rate))
|
||||
|
||||
|
||||
if epoch % 5000 == 0:
|
||||
if epoch % 2500 == 0:
|
||||
if (math.isnan(self.current_loss)!=True):
|
||||
self.all_losses.append(self.current_loss / 5000)
|
||||
self.all_losses.append(self.current_loss / 2500)
|
||||
learning_rates.append(self.learning_rate)
|
||||
times.append(self.helper.timeSince(start))
|
||||
self.current_loss = 0
|
||||
else:
|
||||
break
|
||||
|
||||
# Plot loss curve
|
||||
# Initialise the subplot function using number of rows and columns
|
||||
figure, axs = plt.subplots(2,sharex=True)
|
||||
figure.suptitle("Loss")
|
||||
# plt.figure()
|
||||
axs[0].plot(self.all_losses,learning_rates,'tab:orange')
|
||||
axs[1].plot(self.all_losses,times,'tab:green')
|
||||
|
||||
plt.figure()
|
||||
plt.plot(self.all_losses)
|
||||
plt.ylabel("Loss")
|
||||
plt.xlabel('Epoch')
|
||||
# # Title and display the plot
|
||||
plt.title('Losses Vs No of Epoch')
|
||||
for ax in axs.flat:
|
||||
ax.set(xlabel='Loss')
|
||||
|
||||
# plt.ylabel("Loss")
|
||||
# plt.xlabel('Learning rate')
|
||||
# # # Title and display the plot
|
||||
# ax1.set_title('Losses Vs Learning rate')
|
||||
plt.savefig("lossinfo")
|
||||
Loading…
Reference in a new issue