Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
Tools
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
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
Service Desk
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
3pia
CMS Analyses
Tools
Commits
3da6d10c
Commit
3da6d10c
authored
3 years ago
by
Dennis Noll
Browse files
Options
Downloads
Patches
Plain Diff
[keras] layer: init Blackout layer - can be used to zero certain parts of tensors
parent
6671b720
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
keras.py
+21
-1
21 additions, 1 deletion
keras.py
with
21 additions
and
1 deletion
keras.py
+
21
−
1
View file @
3da6d10c
...
...
@@ -2,7 +2,7 @@
import
itertools
from
functools
import
cached_property
import
gc
from
collections
import
OrderedDict
,
defaultdict
from
collections
import
OrderedDict
,
defaultdict
,
Iterable
import
fnmatch
import
math
import
datetime
...
...
@@ -177,6 +177,26 @@ class KFeed(object):
)
def
Blackout
(
ref
,
slic
,
name
=
None
):
"""
Blackout (set to zero) values in tensor accoring to numpy like slices. Always done alogn zeroth axis.
Args:
ref (np.array): reference array for shape and dtype
slic (Iterable): iterable of numpy like slices
name (_type_, optional): _description_. Defaults to None.
Returns:
_type_: _description_
"""
shape
=
ref
.
shape
[
1
:]
dtype
=
ref
.
dtype
mask
=
np
.
ones
(
shape
,
dtype
=
dtype
)
slic
=
slic
if
isinstance
(
slic
,
Iterable
)
else
(
slic
,)
for
_slic
in
slic
:
mask
[
_slic
]
=
0
return
tf
.
keras
.
layers
.
Lambda
((
lambda
x
:
x
*
mask
),
name
=
name
)
def
Normal
(
ref
,
const
=
None
,
ignore_zeros
=
False
,
name
=
None
,
**
kwargs
):
"""
Normalizing layer according to ref.
...
...
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