Skip to content

Commit

Permalink
mdb
Browse files Browse the repository at this point in the history
  • Loading branch information
Panos committed Nov 27, 2017
1 parent ca3e0c2 commit fbce25b
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/encoders_decoders.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from tflearn.layers.normalization import batch_normalization
from tflearn.layers.core import fully_connected, dropout

from .. fundamentals.utils import expand_scope_by_name, replicate_parameter_for_all_layers
from . tf_utils import expand_scope_by_name, replicate_parameter_for_all_layers


def encoder_with_convs_and_symmetry_new(in_signal, n_filters=[64, 128, 256, 1024], filter_sizes=[1], strides=[1],
Expand Down
42 changes: 42 additions & 0 deletions src/tf_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
'''
Created on November 26, 2017
@author: optas
'''

import tensorflow as tf
import numpy as np


def expand_scope_by_name(scope, name):
""" expand tf scope by given name.
"""

if isinstance(scope, basestring):
scope += '/' + name
return scope

if scope is not None:
return scope.name + '/' + name
else:
return scope


def replicate_parameter_for_all_layers(parameter, n_layers):
if parameter is not None and len(parameter) != n_layers:
if len(parameter) != 1:
raise ValueError()
parameter = np.array(parameter)
parameter = parameter.repeat(n_layers).tolist()
return parameter


def leaky_relu(alpha):
if not (alpha < 1 and alpha > 0):
raise ValueError()

return lambda x: tf.maximum(alpha * x, x)


def safe_log(x, eps=1e-12):
return tf.log(tf.maximum(x, eps))
18 changes: 0 additions & 18 deletions src/utils.py

This file was deleted.

0 comments on commit fbce25b

Please sign in to comment.