api.md 950 字节
Newer Older
Y
Yi Wang 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
import yi_json

g = 100
def read():
    queue q;
    # warmup q
    for i = 0 : 1000
        q.push(read())
    yield q.shuffle_get()

input = paddle.layer.data(...)
intermediate = paddle.layers.fc(input)
output = paddle.layer.softmax(intermediate)

model = paddle.model.create(output)

train(model, data_provider=read, cluster="clusterId")

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

# 1. package, docker build, docker push
# 2. kubectl, clusterId Kuberentes job, 10 trainer containers, 5 parameter server containers

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

def train():
    if os.environ["kube_api_server"] == nil:
        docker_build()
        docker_push()
        kube_ctrl_start_job()
    else:
        rank = kube_mpi_rank()
        if rank == 0:
            master()
        elif rank >= 15:
            parameter_server()
        else:
            _train()