示例#1
0
def builder(inputs=None):
    return models.dense_classifier(builder_dims,
                                   inputs=inputs,
                                   act_fn=activation_func,
                                   optimizer=builder_opt,
                                   epoch=True)
示例#2
0
builder_opt = tf.train.AdagradOptimizer(learning_rate)
builder_dims = [784, 100, 10]

# ------------------------------------------------------------------------- #

# Dataset instantiation
dataset = datasets.load_mnist()
train_set = dataset.cut(0, 50000, 50000).shuffle().cut(0, 50000, batch_size)
test_set = dataset.cut(50000, 60000, 10000)

# Model instantiation
graph = tf.Graph()
with graph.as_default():
    model = models.dense_classifier(builder_dims,
                                    inputs=None,
                                    act_fn=activation_func,
                                    optimizer=builder_opt,
                                    epoch=True)

# Establish connections with workers
sockets = []
for worker_HOST in worker_HOSTS:
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.connect(worker_HOST)
    sockets.append(s)

# Testing + Training
with graph.as_default():
    sess = tf.Session(graph=graph)

    with sess.as_default():