Difference between revisions of "RNNs with Darknet"

From Interaction Station Wiki
Jump to navigation Jump to search
 
(10 intermediate revisions by 2 users not shown)
Line 3: Line 3:
 
*[[Darknet Installation]]
 
*[[Darknet Installation]]
  
== Using RNNs with Darknet ==
+
== Producing text with a pre-trained model ==
  
*Getting some calculated weights from several writers:
+
*Download some pre-trained models or calculated weights from several writers:
 
  wget https://pjreddie.com/media/files/shakespeare.weights
 
  wget https://pjreddie.com/media/files/shakespeare.weights
 
  wget https://pjreddie.com/media/files/kant.weights
 
  wget https://pjreddie.com/media/files/kant.weights
Line 14: Line 14:
 
*Login & password: interactionstation
 
*Login & password: interactionstation
 
*We first need to open the terminal
 
*We first need to open the terminal
*Then we need to go to the darknet directory. Try typing ''cd darknet'' and press the Enter key. In some computers is installed in another directory and you need to type cd /media/Machine_Learning/darknet:
+
*Then we need to go to the darknet directory. Try typing:
*Then we are going to type:
+
cd darknet
 +
*and press the Enter key.  
 +
In some computers is installed in another directory and you need to type:
 +
cd /media/Machine_Learning/darknet
 +
*Then we are going to type:
 
  ./darknet rnn generate cfg/rnn.cfg shakespeare.weights -srand 0
 
  ./darknet rnn generate cfg/rnn.cfg shakespeare.weights -srand 0
  
 
*Parameters:
 
*Parameters:
*srand N -> N determines the random seed.  
+
*-srand N -> N determines the random seed.  
 
*To be able to generate new texts, instead of 0 use another number.
 
*To be able to generate new texts, instead of 0 use another number.
 +
*-len N -> change the length of text generated, default 1,000
 +
*-seed Word -> It sets the first word of the generated text
  
'''Training with other corpus of text'''
+
== Train the RNNs with another corpus of text ==
  
*Download a text file. Some corpus of text online:
+
*Download a text file. Here you can find some corpus of text online:
 
  George Meredith
 
  George Meredith
 
  http://www.gutenberg.org/ebooks/4500
 
  http://www.gutenberg.org/ebooks/4500
Line 39: Line 45:
  
 
*Parameters:
 
*Parameters:
*srand N -> N determines the random seed.  
+
*-srand N -> N determines the random seed.  
 
*To be able to generate new texts, instead of 0 use another number.
 
*To be able to generate new texts, instead of 0 use another number.
 +
*-len N -> change the length of text generated, default 1,000
 +
*-seed Word -> It sets the first word of the generated text
  
 
*Optional: We can modify file cfg/rnn.train.cfg file  (batch = 50 is the value we set by default, the original value was 256)
 
*Optional: We can modify file cfg/rnn.train.cfg file  (batch = 50 is the value we set by default, the original value was 256)
  
*More info:
+
==More information ==
 +
*RNNs with Darknet:
 
*https://pjreddie.com/darknet/rnns-in-darknet/
 
*https://pjreddie.com/darknet/rnns-in-darknet/
 +
*Terminal basic tutorial:
 +
*https://maker.pro/linux/tutorial/basic-linux-commands-for-beginners
 +
*Recurrent Neural Networks:
 +
*https://skymind.ai/wiki/lstm
  
Terminal basic tutorial: https://maker.pro/linux/tutorial/basic-linux-commands-for-beginners
+
 
 +
[[Category:Natural Language Processing]]

Latest revision as of 14:45, 28 November 2022

Installing Darknet

Producing text with a pre-trained model

  • Download some pre-trained models or calculated weights from several writers:
wget https://pjreddie.com/media/files/shakespeare.weights
wget https://pjreddie.com/media/files/kant.weights
wget https://pjreddie.com/media/files/tolstoy.weights
  • Example: Generating a text based on the pre-trained model with books written by Shakespeare with Darknet:
  • The machine learning framework Darknet, is installed in the black PCs of the Interaction Station. We will use the operating system Ubuntu (Linux):
  • Login & password: interactionstation
  • We first need to open the terminal
  • Then we need to go to the darknet directory. Try typing:
cd darknet
  • and press the Enter key.

In some computers is installed in another directory and you need to type:

cd /media/Machine_Learning/darknet
  • Then we are going to type:
./darknet rnn generate cfg/rnn.cfg shakespeare.weights -srand 0
  • Parameters:
  • -srand N -> N determines the random seed.
  • To be able to generate new texts, instead of 0 use another number.
  • -len N -> change the length of text generated, default 1,000
  • -seed Word -> It sets the first word of the generated text

Train the RNNs with another corpus of text

  • Download a text file. Here you can find some corpus of text online:
George Meredith
http://www.gutenberg.org/ebooks/4500
Mark Twain
http://www.gutenberg.org/ebooks/3200
More
http://www.gutenberg.org/ebooks/search/?query=The+Complete+Works+of
  • We train the neural network with the new text (This might take a while):
./darknet rnn train cfg/rnn.train.cfg -file filename.txt
  • Generating new text with our new model
./darknet rnn generate cfg/rnn.cfg filename.weights -srand 0
  • Parameters:
  • -srand N -> N determines the random seed.
  • To be able to generate new texts, instead of 0 use another number.
  • -len N -> change the length of text generated, default 1,000
  • -seed Word -> It sets the first word of the generated text
  • Optional: We can modify file cfg/rnn.train.cfg file (batch = 50 is the value we set by default, the original value was 256)

More information