Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
macaon
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
Franck Dary
macaon
Commits
8946a076
Commit
8946a076
authored
4 years ago
by
Franck Dary
Browse files
Options
Downloads
Patches
Plain Diff
Added RandomNetwork
parent
a43b9993
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
reading_machine/src/Classifier.cpp
+9
-0
9 additions, 0 deletions
reading_machine/src/Classifier.cpp
torch_modules/include/RandomNetwork.hpp
+18
-0
18 additions, 0 deletions
torch_modules/include/RandomNetwork.hpp
torch_modules/src/RandomNetwork.cpp
+19
-0
19 additions, 0 deletions
torch_modules/src/RandomNetwork.cpp
with
46 additions
and
0 deletions
reading_machine/src/Classifier.cpp
+
9
−
0
View file @
8946a076
...
...
@@ -5,6 +5,7 @@
#include
"RLTNetwork.hpp"
#include
"CNNNetwork.hpp"
#include
"LSTMNetwork.hpp"
#include
"RandomNetwork.hpp"
Classifier
::
Classifier
(
const
std
::
string
&
name
,
const
std
::
string
&
topology
,
const
std
::
string
&
tsFile
)
{
...
...
@@ -32,6 +33,14 @@ void Classifier::initNeuralNetwork(const std::string & topology)
{
static
std
::
vector
<
std
::
tuple
<
std
::
regex
,
std
::
string
,
std
::
function
<
void
(
const
std
::
smatch
&
)
>>>
initializers
{
{
std
::
regex
(
"Random"
),
"Random : Output is chosen at random."
,
[
this
,
topology
](
auto
sm
)
{
this
->
nn
.
reset
(
new
RandomNetworkImpl
(
this
->
transitionSet
->
size
()));
}
},
{
std
::
regex
(
"OneWord
\\
(([+
\\
-]?
\\
d+)
\\
)"
),
"OneWord(focusedIndex) : Only use the word embedding of the focused word."
,
...
...
This diff is collapsed.
Click to expand it.
torch_modules/include/RandomNetwork.hpp
0 → 100644
+
18
−
0
View file @
8946a076
#ifndef RANDOMNETWORK__H
#define RANDOMNETWORK__H
#include
"NeuralNetwork.hpp"
class
RandomNetworkImpl
:
public
NeuralNetworkImpl
{
private
:
long
outputSize
;
public
:
RandomNetworkImpl
(
long
outputSize
);
torch
::
Tensor
forward
(
torch
::
Tensor
input
)
override
;
};
#endif
This diff is collapsed.
Click to expand it.
torch_modules/src/RandomNetwork.cpp
0 → 100644
+
19
−
0
View file @
8946a076
#include
"RandomNetwork.hpp"
RandomNetworkImpl
::
RandomNetworkImpl
(
long
outputSize
)
:
outputSize
(
outputSize
)
{
setBufferContext
({
0
});
setStackContext
({});
setBufferFocused
({});
setStackFocused
({});
setColumns
({
"FORM"
});
}
torch
::
Tensor
RandomNetworkImpl
::
forward
(
torch
::
Tensor
input
)
{
if
(
input
.
dim
()
==
1
)
input
=
input
.
unsqueeze
(
0
);
return
torch
::
randn
({
input
.
size
(
0
),
outputSize
},
torch
::
TensorOptions
().
device
(
device
).
requires_grad
(
true
));
}
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