Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
J
java-wowa-training
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cylab
java-wowa-training
Commits
0c52e8a9
Commit
0c52e8a9
authored
5 years ago
by
a.croix
Browse files
Options
Downloads
Patches
Plain Diff
Set neural network on specific branch
parent
45204932
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#1821
passed
5 years ago
Stage: leaks
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
pom.xml
+0
-11
0 additions, 11 deletions
pom.xml
src/main/java/be/cylab/java/wowa/training/MainDL4J.java
+0
-103
0 additions, 103 deletions
src/main/java/be/cylab/java/wowa/training/MainDL4J.java
with
0 additions
and
114 deletions
pom.xml
+
0
−
11
View file @
0c52e8a9
...
...
@@ -98,17 +98,6 @@
<version>
0.0.3
</version>
</dependency>
<dependency>
<groupId>
org.nd4j
</groupId>
<artifactId>
nd4j-native-platform
</artifactId>
<version>
0.9.1
</version>
</dependency>
<dependency>
<groupId>
org.deeplearning4j
</groupId>
<artifactId>
deeplearning4j-core
</artifactId>
<version>
0.9.1
</version>
</dependency>
</dependencies>
...
...
This diff is collapsed.
Click to expand it.
src/main/java/be/cylab/java/wowa/training/MainDL4J.java
deleted
100644 → 0
+
0
−
103
View file @
45204932
package
be.cylab.java.wowa.training
;
import
org.datavec.api.records.reader.RecordReader
;
import
org.datavec.api.records.reader.impl.csv.CSVRecordReader
;
import
org.datavec.api.split.FileSplit
;
import
org.datavec.api.util.ClassPathResource
;
import
org.deeplearning4j.datasets.datavec.RecordReaderDataSetIterator
;
import
org.deeplearning4j.eval.Evaluation
;
import
org.deeplearning4j.nn.conf.MultiLayerConfiguration
;
import
org.deeplearning4j.nn.conf.NeuralNetConfiguration
;
import
org.deeplearning4j.nn.conf.layers.DenseLayer
;
import
org.deeplearning4j.nn.conf.layers.OutputLayer
;
import
org.deeplearning4j.nn.multilayer.MultiLayerNetwork
;
import
org.deeplearning4j.nn.weights.WeightInit
;
import
org.nd4j.linalg.activations.Activation
;
import
org.nd4j.linalg.api.ndarray.INDArray
;
import
org.nd4j.linalg.dataset.DataSet
;
import
org.nd4j.linalg.dataset.SplitTestAndTrain
;
import
org.nd4j.linalg.dataset.api.iterator.DataSetIterator
;
import
org.nd4j.linalg.dataset.api.preprocessor.DataNormalization
;
import
org.nd4j.linalg.dataset.api.preprocessor.NormalizerStandardize
;
import
org.nd4j.linalg.lossfunctions.LossFunctions
;
import
java.io.IOException
;
/**
* Class for learn in neuronal network.
*/
public
final
class
MainDL4J
{
/**
* Default constructor.
*/
private
MainDL4J
()
{
}
/**
* Class count.
*/
public
static
final
int
CLASSES_COUNT
=
2
;
/**
* Features count.
*/
public
static
final
int
FEATURES_COUNT
=
5
;
/**
* Main class for deep-learning.
*
* @param args
*/
public
static
void
main
(
final
String
[]
args
)
{
try
(
RecordReader
record_reader
=
new
CSVRecordReader
(
0
,
','
))
{
record_reader
.
initialize
(
new
FileSplit
(
new
ClassPathResource
(
"webshell_data.csv"
).
getFile
()
));
DataSetIterator
iterator
=
new
RecordReaderDataSetIterator
(
record_reader
,
12468
,
FEATURES_COUNT
,
CLASSES_COUNT
);
DataSet
all_data
=
iterator
.
next
();
all_data
.
shuffle
();
DataNormalization
normalizer
=
new
NormalizerStandardize
();
normalizer
.
fit
(
all_data
);
normalizer
.
transform
(
all_data
);
SplitTestAndTrain
test_and_train
=
all_data
.
splitTestAndTrain
(
0.75
);
DataSet
training_data
=
test_and_train
.
getTrain
();
DataSet
test_data
=
test_and_train
.
getTest
();
MultiLayerConfiguration
configuration
=
new
NeuralNetConfiguration
.
Builder
()
.
iterations
(
1000
)
.
activation
(
Activation
.
TANH
)
.
weightInit
(
WeightInit
.
XAVIER
)
.
learningRate
(
0.1
)
.
regularization
(
true
).
l2
(
0.0001
)
.
list
()
.
layer
(
0
,
new
DenseLayer
.
Builder
().
nIn
(
FEATURES_COUNT
).
nOut
(
10
).
build
())
.
layer
(
1
,
new
DenseLayer
.
Builder
().
nIn
(
10
).
nOut
(
10
).
build
())
.
layer
(
2
,
new
OutputLayer
.
Builder
(
LossFunctions
.
LossFunction
.
NEGATIVELOGLIKELIHOOD
)
.
activation
(
Activation
.
SOFTMAX
)
.
nIn
(
10
).
nOut
(
CLASSES_COUNT
).
build
())
.
backprop
(
true
).
pretrain
(
false
)
.
build
();
MultiLayerNetwork
model
=
new
MultiLayerNetwork
(
configuration
);
model
.
init
();
model
.
fit
(
training_data
);
INDArray
output
=
model
.
output
((
test_data
.
getFeatureMatrix
()));
Evaluation
eval
=
new
Evaluation
(
CLASSES_COUNT
);
eval
.
eval
(
test_data
.
getLabels
(),
output
);
System
.
out
.
println
(
eval
.
stats
());
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment