def graph_builder(opts, inputs):
    output = dense(opts, inputs['inputs'])
    if opts.train:
        loss = tf.reduce_mean(output)
        optimiser = tf.train.GradientDescentOptimizer(0.01)
        with tf.variable_scope('train', reuse=tf.AUTO_REUSE):
            global_step = tf.get_variable('step_control', dtype=tf.int32, shape=[])
            grads_and_vars = optimiser.compute_gradients(loss, tf.trainable_variables())
            train = optimiser.apply_gradients(grads_and_vars, global_step)
            with tf.control_dependencies([train]):
                global_step = tf.identity(global_step)
            return global_step
    return output
def graph_builder(opts, inputs):
    output = dense(opts, inputs['inputs'])
    if opts.train:
        loss = tf.reduce_mean(output)
        optimiser = tf.train.GradientDescentOptimizer(0.01)
        with tf.variable_scope('train', reuse=tf.AUTO_REUSE):
            global_step = tf.get_variable('step_control', dtype=tf.int32, shape=[])
            grads_and_vars = optimiser.compute_gradients(loss, tf.trainable_variables())
            train = optimiser.apply_gradients(grads_and_vars, global_step)
            with tf.control_dependencies([train]):
                global_step = tf.identity(global_step)
            return global_step
    return output