Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
KerasROOTClassification
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nikolai.Hartmann
KerasROOTClassification
Commits
87b25c46
Commit
87b25c46
authored
6 years ago
by
Nikolai.Hartmann
Browse files
Options
Downloads
Patches
Plain Diff
allow different number of nodes per layer
parent
96a77543
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
toolkit.py
+10
-4
10 additions, 4 deletions
toolkit.py
with
10 additions
and
4 deletions
toolkit.py
+
10
−
4
View file @
87b25c46
...
...
@@ -106,7 +106,7 @@ class ClassificationProject(object):
:param layers: number of layers in the neural network
:param nodes: number of nodes in each layer
:param nodes:
list
number of nodes in each layer
. If only a single number is given, use this number for every layer
:param dropout: dropout fraction after each hidden layer. Set to None for no Dropout
...
...
@@ -230,6 +230,12 @@ class ClassificationProject(object):
self
.
identifiers
=
identifiers
self
.
layers
=
layers
self
.
nodes
=
nodes
if
not
isinstance
(
self
.
nodes
,
list
):
self
.
nodes
=
[
self
.
nodes
for
i
in
range
(
self
.
layers
)]
if
len
(
self
.
nodes
)
!=
self
.
layers
:
self
.
layers
=
len
(
self
.
nodes
)
logger
.
warning
(
"
Number of layers not equal to the given nodes
"
"
per layer - adjusted to
"
+
str
(
self
.
layers
))
self
.
dropout
=
dropout
self
.
batch_size
=
batch_size
self
.
validation_split
=
validation_split
...
...
@@ -551,10 +557,10 @@ class ClassificationProject(object):
self
.
_model
=
Sequential
()
# first hidden layer
self
.
_model
.
add
(
Dense
(
self
.
nodes
,
input_dim
=
len
(
self
.
branches
),
activation
=
self
.
activation_function
))
self
.
_model
.
add
(
Dense
(
self
.
nodes
[
0
]
,
input_dim
=
len
(
self
.
branches
),
activation
=
self
.
activation_function
))
# the other hidden layers
for
layer_number
in
range
(
self
.
layers
-
1
):
self
.
_model
.
add
(
Dense
(
self
.
nodes
,
activation
=
self
.
activation_function
))
for
node_count
,
layer_number
in
zip
(
self
.
nodes
[
1
:],
range
(
self
.
layers
-
1
)
)
:
self
.
_model
.
add
(
Dense
(
node_count
,
activation
=
self
.
activation_function
))
if
self
.
dropout
is
not
None
:
self
.
_model
.
add
(
Dropout
(
rate
=
self
.
dropout
))
# last layer is one neuron (binary classification)
...
...
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