Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
aidge_core
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
Model registry
Operate
Environments
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
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Cyril Moineau
aidge_core
Commits
74a582a1
Commit
74a582a1
authored
1 year ago
by
Maxence Naud
Browse files
Options
Downloads
Patches
Plain Diff
[Upd] BatchNorm factory to build its parameters at creation
parent
631de16f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/aidge/operator/BatchNorm.hpp
+8
-7
8 additions, 7 deletions
include/aidge/operator/BatchNorm.hpp
python_binding/operator/pybind_BatchNorm.cpp
+1
-1
1 addition, 1 deletion
python_binding/operator/pybind_BatchNorm.cpp
with
9 additions
and
8 deletions
include/aidge/operator/BatchNorm.hpp
+
8
−
7
View file @
74a582a1
...
...
@@ -82,9 +82,9 @@ public:
associated
&=
!
(
getInput
(
i
)
->
empty
());
}
if
(
associated
)
{
const
DimSize_t
nb
Channel
s
=
getInput
(
0
)
->
dims
()[
1
];
const
DimSize_t
nb
Feature
s
=
getInput
(
0
)
->
dims
()[
1
];
for
(
std
::
size_t
i
=
nbData
();
i
<
nbInputs
();
++
i
)
{
if
(
getInput
(
i
)
->
size
()
!=
nb
Channel
s
)
{
if
(
getInput
(
i
)
->
size
()
!=
nb
Feature
s
)
{
// /!\ Input size should be handled BEFORE calling this function
// This should raise an error
getInput
(
i
)
->
resize
(
std
::
array
<
DimSize_t
,
1
>
({
getInput
(
0
)
->
dims
()[
1
]}));
...
...
@@ -117,15 +117,16 @@ template <DimIdx_t DIM>
const
std
::
string
BatchNorm_Op
<
DIM
>::
Type
=
"BatchNorm"
;
template
<
DimSize_t
DIM
>
inline
std
::
shared_ptr
<
Node
>
BatchNorm
(
const
float
epsilon
=
1.0e-5
F
,
inline
std
::
shared_ptr
<
Node
>
BatchNorm
(
const
DimSize_t
nbFeatures
,
const
float
epsilon
=
1.0e-5
F
,
const
float
momentum
=
0.1
F
,
const
std
::
string
&
name
=
""
)
{
static_assert
(
DIM
<=
MaxDim
,
"Too many kernel dimensions required by BatchNorm, not supported"
);
auto
batchNorm
=
std
::
make_shared
<
Node
>
(
std
::
make_shared
<
BatchNorm_Op
<
static_cast
<
DimIdx_t
>
(
DIM
)
>>
(
epsilon
,
momentum
),
name
);
addProducer
(
batchNorm
,
1
,
std
::
array
<
DimSize_t
,
0
>
({}),
"scale"
);
addProducer
(
batchNorm
,
2
,
std
::
array
<
DimSize_t
,
0
>
({}),
"shift"
);
addProducer
(
batchNorm
,
3
,
std
::
array
<
DimSize_t
,
0
>
({}),
"batch_mean"
);
addProducer
(
batchNorm
,
4
,
std
::
array
<
DimSize_t
,
0
>
({}),
"batch_variance"
);
addProducer
(
batchNorm
,
1
,
std
::
array
<
DimSize_t
,
1
>
({
nbFeatures
}),
"scale"
);
addProducer
(
batchNorm
,
2
,
std
::
array
<
DimSize_t
,
1
>
({
nbFeatures
}),
"shift"
);
addProducer
(
batchNorm
,
3
,
std
::
array
<
DimSize_t
,
1
>
({
nbFeatures
}),
"batch_mean"
);
addProducer
(
batchNorm
,
4
,
std
::
array
<
DimSize_t
,
1
>
({
nbFeatures
}),
"batch_variance"
);
return
batchNorm
;
}
}
// namespace Aidge
...
...
This diff is collapsed.
Click to expand it.
python_binding/operator/pybind_BatchNorm.cpp
+
1
−
1
View file @
74a582a1
...
...
@@ -25,7 +25,7 @@ void declare_BatchNormOp(py::module& m) {
.
def
(
"get_inputs_name"
,
&
BatchNorm_Op
<
DIM
>::
getInputsName
)
.
def
(
"get_outputs_name"
,
&
BatchNorm_Op
<
DIM
>::
getOutputsName
);
m
.
def
((
"BatchNorm"
+
std
::
to_string
(
DIM
)
+
"D"
).
c_str
(),
&
BatchNorm
<
DIM
>
,
py
::
arg
(
"epsilon"
)
=
1.0e-5
F
,
py
::
arg
(
"momentum"
)
=
0.1
F
,
py
::
arg
(
"name"
)
=
""
);
m
.
def
((
"BatchNorm"
+
std
::
to_string
(
DIM
)
+
"D"
).
c_str
(),
&
BatchNorm
<
DIM
>
,
py
::
arg
(
"nbFeatures"
),
py
::
arg
(
"epsilon"
)
=
1.0e-5
F
,
py
::
arg
(
"momentum"
)
=
0.1
F
,
py
::
arg
(
"name"
)
=
""
);
}
void
init_BatchNorm
(
py
::
module
&
m
)
{
...
...
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