def model_fn(features, labels, mode):
    (output, predictions) = slp(features['x'], 10)
    loss = tf.losses.sparse_softmax_cross_entropy(tf.cast(labels, tf.int32), output)
    eval_metric_ops = {'accuracy': tf.metrics.accuracy(labels=labels, predictions=predictions)}
    optimizer = tf.train.GradientDescentOptimizer(0.1)
    from kungfu.tensorflow.optimizers import SynchronousSGDOptimizer
    optimizer = SynchronousSGDOptimizer(optimizer)
    train_op = optimizer.minimize(loss, global_step=tf.train.get_global_step())
    return tf.estimator.EstimatorSpec(mode=mode, loss=loss, train_op=train_op, eval_metric_ops=eval_metric_ops)
def model_fn(features, labels, mode):
    (output, predictions) = slp(features['x'], 10)
    loss = tf.losses.sparse_softmax_cross_entropy(tf.cast(labels, tf.int32), output)
    eval_metric_ops = {'accuracy': tf.metrics.accuracy(labels=labels, predictions=predictions)}
    optimizer = tf.train.GradientDescentOptimizer(0.1)
    from kungfu.tensorflow.optimizers import SynchronousSGDOptimizer
    optimizer = SynchronousSGDOptimizer(optimizer)
    train_op = optimizer.minimize(loss, global_step=tf.train.get_global_step())
    return tf.estimator.EstimatorSpec(mode=mode, loss=loss, train_op=train_op, eval_metric_ops=eval_metric_ops)