def get_inputs(train): """Construct distorted input for CIFAR using the Reader ops. """ if train: images, labels = cifar10_input.distorted_inputs(data_dir=FLAGS.data_dir, batch_size=FLAGS.batch_size) else: images, labels = cifar10_input.inputs(eval_data=train, data_dir=FLAGS.data_dir, batch_size=FLAGS.batch_size) print(images) if FLAGS.use_fp16: images = tf.cast(images, tf.float16) labels = tf.cast(labels, tf.float16) return images, labels
def get_inputs(train): """Construct distorted input for CIFAR using the Reader ops. """ if train: images, labels = cifar10_input.distorted_inputs( data_dir=FLAGS.data_dir, batch_size=FLAGS.batch_size) else: images, labels = cifar10_input.inputs(eval_data=train, data_dir=FLAGS.data_dir, batch_size=FLAGS.batch_size) print(images) if FLAGS.use_fp16: images = tf.cast(images, tf.float16) labels = tf.cast(labels, tf.float16) return images, labels
def score(logits, labels): """Add L2Loss to all the trainable variables. """ # Calculate the average cross entropy loss across the batch. labels = tf.cast(labels, tf.int64) cross_entropy = tf.nn.sparse_softmax_cross_entropy_with_logits( logits, labels, name='cross_entropy_per_example') cross_entropy_mean = tf.reduce_mean(cross_entropy, name='cross_entropy') tf.add_to_collection('losses', cross_entropy_mean) # The total loss is defined as the cross entropy loss plus all of the weight # decay terms (L2 loss). return tf.add_n(tf.get_collection('losses'), name='total_loss')