forked from evolvingstuff/RecurrentJava
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExampleLilDicky.java
More file actions
46 lines (37 loc) · 1.58 KB
/
Copy pathExampleLilDicky.java
File metadata and controls
46 lines (37 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import datasets.TextGenerationUnbroken;
import datastructs.DataSet;
import model.Model;
import trainer.Trainer;
import util.NeuralNetworkHelper;
import java.util.Random;
public class ExampleLilDicky
{
public static void main(String[] args)
throws Exception
{
Random rng = new Random();
int totalSequences = 2000;
int sequenceMinLength = 10;
int sequenceMaxLength = 100;
String textSource = "LilDicky";
DataSet data = new TextGenerationUnbroken("datasets/text/" + textSource + ".txt", totalSequences, sequenceMinLength, sequenceMaxLength, rng);
String savePath = "saved_models/" + textSource + ".ser";
boolean initFromSaved = true; //set this to false to start with a fresh model
boolean overwriteSaved = true;
TextGenerationUnbroken.reportSequenceLength = 500;
int bottleneckSize = 10; //one-hot input is squeezed through this
int hiddenDimension = 200;
int hiddenLayers = 1;
double learningRate = 0.001;
double initParamsStdDev = 0.08;
Model lstm = NeuralNetworkHelper.makeLstmWithInputBottleneck(
data.inputDimension, bottleneckSize,
hiddenDimension, hiddenLayers,
data.outputDimension, data.getModelOutputUnitToUse(),
initParamsStdDev, rng);
int reportEveryNthEpoch = 10;
int trainingEpochs = 1000;
Trainer.train(trainingEpochs, learningRate, lstm, data, reportEveryNthEpoch, initFromSaved, overwriteSaved, savePath, rng);
System.out.println("done.");
}
}