-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Panos
committed
Nov 27, 2017
1 parent
ca3e0c2
commit fbce25b
Showing
3 changed files
with
43 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) |
This file was deleted.
Oops, something went wrong.