Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
Troubled Cell Detection
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Laura Christine Kühle
Troubled Cell Detection
Commits
878327a9
Commit
878327a9
authored
3 years ago
by
Laura Christine Kühle
Browse files
Options
Downloads
Patches
Plain Diff
Added documentation to 'ANN_Model'.
parent
a34d6f4f
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
ANN_Model.py
+42
-3
42 additions, 3 deletions
ANN_Model.py
with
42 additions
and
3 deletions
ANN_Model.py
+
42
−
3
View file @
878327a9
...
...
@@ -8,11 +8,36 @@ INFO: /home/laura/anaconda3/lib/python3.7/site-packages/torch/nn/modules
import
torch
# Define Neural Network
# Model with Linear -> ReLu -> Linear -> ReLu -> Linear -> any activation function
class
ThreeLayerReLu
(
torch
.
nn
.
Module
):
"""
Class for a fully-connected, three-layered ANN with ReLu.
Predicts score for each output class using the following structure:
Linear -> ReLu -> Linear -> ReLu -> Linear -> any activation function
Attributes
----------
name: str
String containing name of model.
input_linear: torch.nn.Module
Linear input layer.
middle_linear: torch.nn.Module
Linear middle layer.
output_linear: torch.nn.Module
Linear output layer.
output_layer: torch.nn.Module
Activation layer for output calculation.
"""
def
__init__
(
self
,
config
):
"""
Initializes ThreeLayerReLu.
Parameters
----------
config : dict
Additional parameters for model.
"""
super
().
__init__
()
input_size
=
config
.
pop
(
'
input_size
'
,
5
)
...
...
@@ -35,6 +60,19 @@ class ThreeLayerReLu(torch.nn.Module):
**
activation_config
)
def
forward
(
self
,
input_data
):
"""
Executes forward propagation.
Parameters
----------
input_data: ndarray
2D array containing input data.
Returns
-------
prediction: ndarray
Matrix containing predicted output data.
"""
prediction
=
self
.
input_linear
(
input_data
).
clamp
(
min
=
0
)
prediction
=
self
.
middle_linear
(
prediction
).
clamp
(
min
=
0
)
prediction
=
self
.
output_linear
(
prediction
)
...
...
@@ -42,4 +80,5 @@ class ThreeLayerReLu(torch.nn.Module):
return
prediction
def
get_name
(
self
):
"""
Returns string of model name.
"""
return
self
.
_name
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