Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
bob
bob.learn.tensorflow
Commits
50eb11a9
Commit
50eb11a9
authored
Aug 10, 2016
by
Tiago de Freitas Pereira
Browse files
Brain dump
parent
17cd04f8
Changes
3
Hide whitespace changes
Inline
Side-by-side
bob/learn/tensorflow/layers/Conv2D.py
View file @
50eb11a9
...
...
@@ -22,7 +22,7 @@ class Conv2D(Layer):
seed
=
10
):
"""
Base c
onstructor
C
onstructor
**Parameters**
input: Layer input
...
...
bob/learn/tensorflow/layers/FullyConnected.py
0 → 100644
View file @
50eb11a9
#!/usr/bin/env python
# vim: set fileencoding=utf-8 :
# @author: Tiago de Freitas Pereira <tiago.pereira@idiap.ch>
# @date: Wed 11 May 2016 17:38 CEST
import
tensoflow
as
tf
from
bob.learn.tensorflow.util
import
*
from
.Layer
import
Layer
class
FullyConnected
(
Layer
):
"""
2D Convolution
"""
def
__init__
(
self
,
input
,
activation
=
None
,
initialization
=
'xavier'
,
use_gpu
=
False
,
seed
=
10
):
"""
Constructor
**Parameters**
input: Layer input
activation: Tensor Flow activation
initialization: Initialization type
use_gpu: Store data in the GPU
seed: Seed for the Random number generation
"""
super
(
FullyConnected
,
self
).
__init__
(
input
,
initialization
=
'xavier'
,
use_gpu
=
False
,
seed
=
10
)
self
.
activation
=
activation
if
len
(
input
.
get_shape
())
==
4
:
self
.
W
=
create_weight_variables
([
kernel_size
,
kernel_size
,
1
,
filters
],
seed
=
seed
,
name
=
"conv"
,
use_gpu
=
use_gpu
)
if
activation
is
not
None
:
self
.
b
=
create_bias_variables
([
filters
],
name
=
"bias"
,
use_gpu
=
self
.
use_gpu
)
def
get_graph
(
self
):
with
tf
.
name_scope
(
'fc'
):
conv
=
tf
.
nn
.
conv2d
(
self
.
input
,
self
.
W
,
strides
=
[
1
,
1
,
1
,
1
],
padding
=
'SAME'
)
if
self
.
activation
is
not
None
:
with
tf
.
name_scope
(
'activation'
):
non_linearity
=
tf
.
nn
.
tanh
(
tf
.
nn
.
bias_add
(
conv
,
self
.
b
))
return
non_linearity
bob/learn/tensorflow/layers/MaxPooling.py
View file @
50eb11a9
...
...
@@ -10,4 +10,11 @@ from .Layer import Layer
class
MaxPooling
(
Layer
):
\ No newline at end of file
def
__init__
(
self
,
input
,
use_gpu
=
False
):
"""
Constructor
"""
super
(
MaxPooling
,
self
).
__init__
(
input
,
use_gpu
=
False
)
def
get_graph
(
self
):
tf
.
nn
.
max_pool
(
self
.
input
,
ksize
=
[
1
,
2
,
2
,
1
],
strides
=
[
1
,
2
,
2
,
1
],
padding
=
'SAME'
)
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment