Oneflow-Inc / oneflow

OneFlow is a deep learning framework designed to be user-friendly, scalable and efficient.
http://www.oneflow.org
Apache License 2.0
5.91k stars 667 forks source link

Could oneflow export tf saved model to do serving ? #3425

Open Yazhou-Liu opened 4 years ago

ShawnXuan commented 4 years ago

Currently, OneFlow can't export tensorflow saved model for serving directly. We understand this kind of requirement, and mark it on oneflow roadmap.

BTW, there is a trick that we used before, only in special cases, most part of oneflow op's api are same with tf's api, if only these ops are choose to build up the NN, it's easy to switch between flow and tf, here is an example:

def build_up_nn(flow, features, labels):
    assert flow.__name__ == 'tensorflow' or flow.__name__ == 'oneflow'
    logits = Backbone(flow, features)
    sigmoid_loss = flow.nn.sigmoid_cross_entropy_with_logits(logits=logits, labels=labels)
    loss = flow.math.reduce_sum(sigmoid_loss, name="sigmoid_loss")
    predict = flow.math.sigmoid(logits , name='probs')
    return loss, predict

Thanks!