Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
lib4neuro
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
MolDyn
lib4neuro
Commits
27c92693
Commit
27c92693
authored
5 years ago
by
Martin Beseda
Browse files
Options
Downloads
Patches
Plain Diff
[ENH] Added functions to get DataSet outputs and inputs as Armadillo matrices.
parent
e2258c44
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/DataSet/DataSet.cpp
+27
-1
27 additions, 1 deletion
src/DataSet/DataSet.cpp
src/DataSet/DataSet.h
+13
-0
13 additions, 0 deletions
src/DataSet/DataSet.h
with
40 additions
and
1 deletion
src/DataSet/DataSet.cpp
+
27
−
1
View file @
27c92693
#include
<algorithm>
#include
<armadillo>
#include
<boost/serialization/export.hpp>
#include
"DataSetSerialization.h"
#include
"exceptions.h"
#include
"DataSet.h"
BOOST_CLASS_EXPORT_IMPLEMENT
(
lib4neuro
::
DataSet
);
...
...
@@ -34,7 +38,6 @@ namespace lib4neuro {
}
this
->
normalization_strategy
=
std
::
make_shared
<
DoubleUnitStrategy
>
(
DoubleUnitStrategy
());
}
DataSet
::
DataSet
(
std
::
vector
<
std
::
pair
<
std
::
vector
<
double
>
,
std
::
vector
<
double
>>>*
data_ptr
,
...
...
@@ -497,4 +500,27 @@ namespace lib4neuro {
}
this
->
output_dim
+=
n_columns
;
}
arma
::
Mat
<
double
>*
DataSet
::
get_inputs_matrix
()
{
this
->
inputs_matrix
=
new
arma
::
Mat
<
double
>
(
this
->
data
.
size
(),
this
->
data
.
at
(
0
).
first
.
size
());
// arma::Mat<double> m(this->data.size(), this->data.at(0).first.size());
for
(
size_t
i
=
0
;
i
<
this
->
data
.
size
();
i
++
)
{
this
->
inputs_matrix
->
row
(
i
)
=
arma
::
Row
<
double
>
(
this
->
data
.
at
(
i
).
first
);
}
// this->inputs_matrix = &m;
return
this
->
inputs_matrix
;
}
arma
::
Mat
<
double
>*
DataSet
::
get_outputs_matrix
()
{
this
->
outputs_matrix
=
new
arma
::
Mat
<
double
>
(
this
->
data
.
size
(),
this
->
data
.
at
(
0
).
second
.
size
());
for
(
size_t
i
=
0
;
i
<
this
->
data
.
size
();
i
++
)
{
this
->
outputs_matrix
->
row
(
i
)
=
arma
::
Row
<
double
>
(
this
->
data
.
at
(
i
).
second
);
}
// this->outputs_matrix = &m;
return
this
->
outputs_matrix
;
}
}
This diff is collapsed.
Click to expand it.
src/DataSet/DataSet.h
+
13
−
0
View file @
27c92693
...
...
@@ -14,6 +14,11 @@
#include
"../settings.h"
#include
"../NormalizationStrategy/NormalizationStrategy.h"
/* Forward declaration or arma::Mat<> type */
namespace
arma
{
template
<
class
T
>
class
Mat
;
}
namespace
lib4neuro
{
/**
...
...
@@ -68,6 +73,10 @@ namespace lib4neuro {
//TODO let user choose in the constructor!
std
::
shared_ptr
<
NormalizationStrategy
>
normalization_strategy
;
arma
::
Mat
<
double
>*
inputs_matrix
;
arma
::
Mat
<
double
>*
outputs_matrix
;
public:
...
...
@@ -314,6 +323,10 @@ namespace lib4neuro {
* @param n_columns Number of columns to be inserted
*/
LIB4NEURO_API
void
add_zero_output_columns
(
size_t
n_columns
);
[[
nodiscard
]]
LIB4NEURO_API
arma
::
Mat
<
double
>*
get_inputs_matrix
();
[[
nodiscard
]]
LIB4NEURO_API
arma
::
Mat
<
double
>*
get_outputs_matrix
();
};
}
#endif //INC_4NEURO_DATASET_H
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