Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
edgeconv_keras
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Test Cases
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dennis Noll
edgeconv_keras
Commits
cabcc01a
Commit
cabcc01a
authored
Oct 10, 2019
by
JGlombitza
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://git.rwth-aachen.de/niklas.langner/edgeconv_keras
parents
963ed935
0ba03bea
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
6 deletions
+17
-6
edgeconv.py
edgeconv.py
+17
-6
No files found.
edgeconv.py
View file @
cabcc01a
"""Implementation of EdgeConv using arbitrary functions as h"""
import
tensorflow
as
tf
import
tensorflow.keras.layers
as
lay
from
tensorflow
import
keras
from
tensorflow.keras
import
backend
as
K
class
EdgeConv
(
lay
.
Layer
):
def
__init__
(
self
,
f
,
name
,
**
kwargs
):
self
.
f
=
f
self
.
h_name
=
name
def
__init__
(
self
,
h_func
,
next_neighbors
,
**
kwargs
):
self
.
h_func
=
h_func
self
.
nn
=
next_neighbors
super
(
EdgeConv
,
self
).
__init__
(
**
kwargs
)
def
build
(
self
,
input_shape
):
# Create a trainable weight variable for this layer.
x
=
lay
.
Input
(
input_shape
)
self
.
f
=
keras
.
models
.
Model
(
x
,
self
.
f
(
x
),
name
=
self
.
h_name
)
self
.
h_func
=
keras
.
models
.
Model
(
x
,
self
.
h_func
(
x
)
)
super
(
EdgeConv
,
self
).
build
(
input_shape
)
# Be sure to call this at the end
def
call
(
self
,
x
):
return
self
.
f
(
x
)
return
self
.
h_func
(
x
)
def
compute_output_shape
(
self
,
input_shape
):
self
.
output_shape
=
self
.
f
.
get_output_shape_at
(
-
1
)
self
.
output_shape
=
self
.
h_func
.
get_output_shape_at
(
-
1
)
return
self
.
output_shape
def
knn
(
X
,
k
):
r
=
K
.
sum
(
X
*
X
,
axis
=
1
,
keepdims
=
True
)
# (N, 1, P_A)
m
=
K
.
batch_dot
(
K
.
permute_dimensions
(
K
.
transpose
(
X
),
(
2
,
0
,
1
)),
X
)
# (N, P_A, P_B)
D
=
lay
.
add
([
lay
.
subtract
([
K
.
permute_dimensions
(
K
.
transpose
(
r
),
(
2
,
0
,
1
)),
2
*
m
]),
r
])
values
,
indices
=
tf
.
nn
.
top_k
(
-
D
,
k
=
k
+
1
)
# (N, P, K+1)
indices
=
K
.
slice
(
indices
,
[
0
,
0
,
1
],
[
X
.
shape
[
0
],
X
.
shape
[
2
],
k
])
# (N, P, K)
return
indices
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment