<s> from __future__ import division , print_function , absolute_import <EOL> import math <EOL> import tensorflow as tf <EOL> from . utils import get_from_module <EOL> def get ( identifier ) : <EOL> if hasattr ( identifier , '<STR_LIT>' ) : <EOL> return identifier <EOL> else : <EOL> return get_from_module ( identifier , globals ( ) , '<STR_LIT>' ) <EOL> def zeros ( shape = None , dtype = tf . float32 , seed = None ) : <EOL> """<STR_LIT>""" <EOL> if shape : <EOL> return tf . zeros ( shape , dtype = dtype ) <EOL> else : <EOL> return tf . constant_initializer ( <NUM_LIT:0.> ) <EOL> def uniform ( shape = None , minval = <NUM_LIT:0> , maxval = None , dtype = tf . float32 , seed = None ) : <EOL> """<STR_LIT>""" <EOL> if shape : <EOL> return tf . random_uniform ( shape , minval = minval , maxval = maxval , <EOL> seed = seed , dtype = dtype ) <EOL> else : <EOL> return tf . random_uniform_initializer ( minval = minval , maxval = maxval , <EOL> seed = seed , dtype = dtype ) <EOL> def uniform_scaling ( shape = None , factor = <NUM_LIT:1.0> , dtype = tf . float32 , seed = None ) : <EOL> """<STR_LIT>""" <EOL> if shape : <EOL> input_size = <NUM_LIT:1.0> <EOL> for dim in shape [ : - <NUM_LIT:1> ] : <EOL> input_size *= float ( dim ) <EOL> max_val = math . sqrt ( <NUM_LIT:3> / input_size ) * factor <EOL> return tf . random_ops . random_uniform ( shape , - max_val , max_val , <EOL> dtype , seed = seed ) <EOL> else : <EOL> return tf . uniform_unit_scaling_initializer ( seed = seed , dtype = dtype ) <EOL> def normal ( shape = None , mean = <NUM_LIT:0.0> , stddev = <NUM_LIT> , dtype = tf . float32 , seed = None ) : <EOL> """<STR_LIT>""" <EOL> if shape : <EOL> return tf . random_normal ( shape , mean = mean , stddev = stddev , seed = seed , <EOL> dtype = dtype ) <EOL> else : <EOL> return tf . random_normal_initializer ( mean = mean , stddev = stddev , <EOL> seed = seed , dtype = dtype ) <EOL> def truncated_normal ( shape = None , mean = <NUM_LIT:0.0> , stddev = <NUM_LIT> , dtype = tf . float32 , <EOL> seed = None ) : <EOL> """<STR_LIT>""" <EOL> if shape : <EOL> return tf . truncated_normal ( shape = shape , mean = mean , stddev = stddev , <EOL> seed = seed , dtype = dtype ) <EOL> else : <EOL> return tf . truncated_normal_initializer ( mean = mean , stddev = stddev , <EOL> seed = seed , dtype = dtype ) </s>
