Utils.py 359 B

12345678910
  1. import numpy as np
  2. import tensorflow as tf
  3. def xavier_init(fan_in, fan_out, constant = 1):
  4. low = -constant * np.sqrt(6.0 / (fan_in + fan_out))
  5. high = constant * np.sqrt(6.0 / (fan_in + fan_out))
  6. return tf.random_uniform((fan_in, fan_out),
  7. minval = low, maxval = high,
  8. dtype = tf.float32)