Skip to content
GitLab
Menu
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
ea72b276
Commit
ea72b276
authored
Sep 08, 2020
by
Amir MOHAMMADI
Browse files
isort -sl -rc .
parent
9f2c4abf
Changes
51
Hide whitespace changes
Inline
Side-by-side
bob/learn/tensorflow/dataset/__init__.py
View file @
ea72b276
import
tensorflow
as
tf
import
numpy
import
os
import
numpy
import
tensorflow
as
tf
import
bob.io.base
DEFAULT_FEATURE
=
{
...
...
bob/learn/tensorflow/dataset/generator.py
View file @
ea72b276
import
tensorflow
as
tf
import
random
import
logging
import
random
import
tensorflow
as
tf
logger
=
logging
.
getLogger
(
__name__
)
...
...
bob/learn/tensorflow/dataset/image.py
View file @
ea72b276
...
...
@@ -2,9 +2,12 @@
# vim: set fileencoding=utf-8 :
# @author: Tiago de Freitas Pereira <tiago.pereira@idiap.ch>
import
tensorflow
as
tf
from
functools
import
partial
from
.
import
append_image_augmentation
,
from_filename_to_tensor
import
tensorflow
as
tf
from
.
import
append_image_augmentation
from
.
import
from_filename_to_tensor
def
shuffle_data_and_labels_image_augmentation
(
...
...
bob/learn/tensorflow/dataset/tfrecords.py
View file @
ea72b276
...
...
@@ -4,16 +4,15 @@ from __future__ import absolute_import
from
__future__
import
division
from
__future__
import
print_function
from
functools
import
partial
import
json
import
logging
import
os
from
functools
import
partial
import
tensorflow
as
tf
from
.
import
DEFAULT_FEATURE
logger
=
logging
.
getLogger
(
__name__
)
TFRECORDS_EXT
=
".tfrecords"
...
...
bob/learn/tensorflow/gan/__init__.py
View file @
ea72b276
from
.
import
spectral_normalization
from
.
import
losses
from
.
import
spectral_normalization
bob/learn/tensorflow/gan/spectral_normalization.py
View file @
ea72b276
...
...
@@ -29,7 +29,8 @@ import re
from
tensorflow.python.framework
import
dtypes
from
tensorflow.python.framework
import
ops
from
tensorflow.python.keras.engine
import
base_layer_utils
as
keras_base_layer_utils
from
tensorflow.python.keras.engine
import
\
base_layer_utils
as
keras_base_layer_utils
from
tensorflow.python.ops
import
array_ops
from
tensorflow.python.ops
import
init_ops
from
tensorflow.python.ops
import
math_ops
...
...
bob/learn/tensorflow/image/__init__.py
View file @
ea72b276
from
.filter
import
gaussian_kernel
,
GaussianFilter
from
.filter
import
GaussianFilter
from
.filter
import
gaussian_kernel
# gets sphinx autodoc done right - don't remove it
def
__appropriate__
(
*
args
):
...
...
bob/learn/tensorflow/loss/BaseLoss.py
View file @
ea72b276
...
...
@@ -3,6 +3,7 @@
# @author: Tiago de Freitas Pereira <tiago.pereira@idiap.ch>
import
logging
import
tensorflow
as
tf
logger
=
logging
.
getLogger
(
__name__
)
...
...
bob/learn/tensorflow/loss/ContrastiveLoss.py
View file @
ea72b276
...
...
@@ -3,7 +3,9 @@
# @author: Tiago de Freitas Pereira <tiago.pereira@idiap.ch>
import
logging
import
tensorflow
as
tf
from
bob.learn.tensorflow.utils
import
compute_euclidean_distance
logger
=
logging
.
getLogger
(
__name__
)
...
...
bob/learn/tensorflow/loss/StyleLoss.py
View file @
ea72b276
...
...
@@ -2,9 +2,10 @@
# vim: set fileencoding=utf-8 :
# @author: Tiago de Freitas Pereira <tiago.pereira@idiap.ch>
import
functools
import
logging
import
tensorflow
as
tf
import
functools
logger
=
logging
.
getLogger
(
__name__
)
...
...
bob/learn/tensorflow/loss/__init__.py
View file @
ea72b276
# from .BaseLoss import mean_cross_entropy_loss, mean_cross_entropy_center_loss
from
.ContrastiveLoss
import
contrastive_loss
from
.TripletLoss
import
triplet_loss
,
triplet_average_loss
,
triplet_fisher_loss
from
.StyleLoss
import
linear_gram_style_loss
,
content_loss
,
denoising_loss
from
.vat
import
VATLoss
from
.pixel_wise
import
PixelWise
from
.center_loss
import
CenterLoss
from
.ContrastiveLoss
import
contrastive_loss
from
.mmd
import
*
from
.pairwise_confusion
import
total_pairwise_confusion
from
.pixel_wise
import
PixelWise
from
.StyleLoss
import
content_loss
from
.StyleLoss
import
denoising_loss
from
.StyleLoss
import
linear_gram_style_loss
from
.TripletLoss
import
triplet_average_loss
from
.TripletLoss
import
triplet_fisher_loss
from
.TripletLoss
import
triplet_loss
from
.utils
import
*
from
.vat
import
VATLoss
# gets sphinx autodoc done right - don't remove it
...
...
bob/learn/tensorflow/loss/center_loss.py
View file @
ea72b276
import
tensorflow
as
tf
# TODO(amir): replace parent class with tf.Module in tensorflow 1.14 and above.
# * pass ``name`` to parent class
# * replace get_variable with tf.Variable
...
...
bob/learn/tensorflow/loss/pairwise_confusion.py
View file @
ea72b276
import
tensorflow
as
tf
from
..utils
import
pdist_safe
,
upper_triangle
from
..utils
import
pdist_safe
from
..utils
import
upper_triangle
def
total_pairwise_confusion
(
prelogits
,
name
=
None
):
...
...
bob/learn/tensorflow/loss/pixel_wise.py
View file @
ea72b276
from
..dataset
import
tf_repeat
from
.utils
import
(
balanced_softmax_cross_entropy_loss_weights
,
balanced_sigmoid_cross_entropy_loss_weights
,
)
import
tensorflow
as
tf
from
..dataset
import
tf_repeat
from
.utils
import
balanced_sigmoid_cross_entropy_loss_weights
from
.utils
import
balanced_softmax_cross_entropy_loss_weights
class
PixelWise
:
"""A pixel wise loss which is just a cross entropy loss but applied to all pixels"""
...
...
bob/learn/tensorflow/loss/vat.py
View file @
ea72b276
...
...
@@ -23,9 +23,10 @@
# SOFTWARE.
import
tensorflow
as
tf
from
functools
import
partial
import
tensorflow
as
tf
def
get_normalized_vector
(
d
):
d
/=
1e-12
+
tf
.
reduce_max
(
...
...
bob/learn/tensorflow/models/alexnet.py
View file @
ea72b276
...
...
@@ -62,6 +62,7 @@ def AlexNet_simplified(name="AlexNet", **kwargs):
if
__name__
==
"__main__"
:
import
pkg_resources
from
bob.learn.tensorflow.utils
import
model_summary
model
=
AlexNet_simplified
()
...
...
bob/learn/tensorflow/models/autoencoder_face.py
View file @
ea72b276
...
...
@@ -4,6 +4,7 @@ Mohammadi, Amir and Bhattacharjee, Sushil and Marcel, Sebastien, ICASSP 2020
"""
import
tensorflow
as
tf
from
bob.learn.tensorflow.models.densenet
import
densenet161
...
...
@@ -114,6 +115,7 @@ def autoencoder_face(z_dim=256, weight_decay=1e-10, decoder_last_act="tanh"):
if
__name__
==
"__main__"
:
import
pkg_resources
from
tabulate
import
tabulate
from
bob.learn.tensorflow.utils
import
model_summary
model
=
ConvDecoder
(
z_dim
=
256
,
weight_decay
=
1e-9
,
last_act
=
"tanh"
,
name
=
"Decoder"
)
...
...
bob/learn/tensorflow/models/densenet.py
View file @
ea72b276
...
...
@@ -3,6 +3,7 @@ Reference [Densely Connected Convolutional Networks](https://arxiv.org/abs/1608.
"""
import
tensorflow
as
tf
from
bob.extension
import
rc
l2
=
tf
.
keras
.
regularizers
.
l2
...
...
@@ -448,6 +449,7 @@ class DeepPixBiS(tf.keras.Model):
if
__name__
==
"__main__"
:
import
pkg_resources
from
tabulate
import
tabulate
from
bob.learn.tensorflow.utils
import
model_summary
def
print_model
(
inputs
,
outputs
):
...
...
bob/learn/tensorflow/models/inception.py
View file @
ea72b276
...
...
@@ -144,6 +144,7 @@ def GoogLeNet(*, num_classes=1000, name="GoogLeNet", **kwargs):
if
__name__
==
"__main__"
:
import
pkg_resources
from
tabulate
import
tabulate
from
bob.learn.tensorflow.utils
import
model_summary
inputs
=
tf
.
keras
.
Input
((
28
,
28
,
192
),
name
=
"input"
)
...
...
bob/learn/tensorflow/models/inception_resnet_v2.py
View file @
ea72b276
# -*- coding: utf-8 -*-
"""Inception-ResNet-V2 MultiScale-Inception-ResNet-V2 models for Keras.
"""
from
tensorflow.keras.models
import
Model
from
tensorflow.keras.layers
import
(
Activation
,
BatchNormalization
,
Concatenate
,
Conv2D
,
Dense
,
Dropout
,
Input
,
Lambda
,
MaxPool2D
,
AvgPool2D
,
GlobalAvgPool2D
,
GlobalMaxPool2D
,
)
from
tensorflow.keras
import
backend
as
K
import
tensorflow
as
tf
import
logging
import
tensorflow
as
tf
from
tensorflow.keras
import
backend
as
K
from
tensorflow.keras.layers
import
Activation
from
tensorflow.keras.layers
import
AvgPool2D
from
tensorflow.keras.layers
import
BatchNormalization
from
tensorflow.keras.layers
import
Concatenate
from
tensorflow.keras.layers
import
Conv2D
from
tensorflow.keras.layers
import
Dense
from
tensorflow.keras.layers
import
Dropout
from
tensorflow.keras.layers
import
GlobalAvgPool2D
from
tensorflow.keras.layers
import
GlobalMaxPool2D
from
tensorflow.keras.layers
import
Input
from
tensorflow.keras.layers
import
Lambda
from
tensorflow.keras.layers
import
MaxPool2D
from
tensorflow.keras.models
import
Model
logger
=
logging
.
getLogger
(
__name__
)
...
...
@@ -696,6 +695,7 @@ def MultiScaleInceptionResNetV2(
if
__name__
==
"__main__"
:
import
pkg_resources
from
tabulate
import
tabulate
from
bob.learn.tensorflow.utils
import
model_summary
def
print_model
(
inputs
,
outputs
,
name
=
None
):
...
...
Prev
1
2
3
Next
Write
Preview
Supports
Markdown
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