Helper to create a Variable stored on CPU memory. Args: name: name of the variable shape: list of ints initializer: initializer for Variable Returns: Variable Tensor
(name, shape, initializer, use_fp16=False, trainable=True)
| 10 | import tensorflow as tf |
| 11 | |
| 12 | def _variable_on_cpu(name, shape, initializer, use_fp16=False, trainable=True): |
| 13 | """Helper to create a Variable stored on CPU memory. |
| 14 | Args: |
| 15 | name: name of the variable |
| 16 | shape: list of ints |
| 17 | initializer: initializer for Variable |
| 18 | Returns: |
| 19 | Variable Tensor |
| 20 | """ |
| 21 | with tf.device('/cpu:0'): |
| 22 | dtype = tf.float16 if use_fp16 else tf.float32 |
| 23 | var = tf.get_variable(name, shape, initializer=initializer, dtype=dtype, trainable=trainable) |
| 24 | return var |
| 25 | |
| 26 | def _variable_with_weight_decay(name, shape, stddev, wd, use_xavier=True): |
| 27 | """Helper to create an initialized Variable with weight decay. |
no outgoing calls
no test coverage detected