Esempio n. 1
0
flags.DEFINE_integer('n_s', 5, 'number of samples')
flags.DEFINE_integer('num_epochs', 200, 'number of epochs to train')
flags.DEFINE_float('lr', 1e-4, 'initial learning rate')

FLAGS = flags.FLAGS

n_s = FLAGS.n_s
NUM_EPOCHS = FLAGS.num_epochs
M = FLAGS.M
n = FLAGS.n
l = FLAGS.l
tau = FLAGS.tau
method = FLAGS.method
initial_rate = FLAGS.lr

train_iterator, val_iterator, test_iterator = mnist_input.get_iterators(
    l, n, 10 ** l - 1, minibatch_size=M) # shape=(1, 3, 112, 28)


false_tensor = tf.convert_to_tensor(False)
evaluation = tf.placeholder_with_default(false_tensor, ())
temperature = tf.cond(evaluation,
                      false_fn=lambda: tf.convert_to_tensor(
                          tau, dtype=tf.float32),
                      true_fn=lambda: tf.convert_to_tensor(
                          1e-10, dtype=tf.float32)  # simulate hard sort
                      )

experiment_id = 'sort-%s-M%d-n%d-l%d-t%d' % (method, M, n, l, tau * 10)
checkpoint_path = 'checkpoints/%s/' % experiment_id

handle = tf.placeholder(tf.string, ())
Esempio n. 2
0
flags.DEFINE_integer('n_s', 5, 'number of samples')
flags.DEFINE_integer('num_epochs', 200, 'number of epochs to train')
flags.DEFINE_float('lr', 1e-4, 'initial learning rate')

FLAGS = flags.FLAGS

n_s = FLAGS.n_s
NUM_EPOCHS = FLAGS.num_epochs
M = FLAGS.M
n = FLAGS.n
l = FLAGS.l
tau = FLAGS.tau
method = FLAGS.method
initial_rate = FLAGS.lr

train_iterator, val_iterator, test_iterator = mnist_input.get_iterators(
    l, n, 10**l - 1, minibatch_size=M)

false_tensor = tf.convert_to_tensor(False)
evaluation = tf.placeholder_with_default(false_tensor, ())
temperature = tf.cond(
    evaluation,
    false_fn=lambda: tf.convert_to_tensor(tau, dtype=tf.float32),
    true_fn=lambda: tf.convert_to_tensor(1e-10, dtype=tf.float32
                                         )  # simulate hard sort
)

experiment_id = 'sort-%s-M%d-n%d-l%d-t%d' % (method, M, n, l, tau * 10)
checkpoint_path = 'checkpoints/%s/' % experiment_id

handle = tf.placeholder(tf.string, ())
X_iterator = tf.data.Iterator.from_string_handle(