caffe: model definition: write same layer with different phase using caffe.NetSpec()

前端 未结 5 715
野性不改
野性不改 2020-12-03 23:00

I want to set up a caffe CNN with python, using caffe.NetSpec() interface. Although I saw we can put test net in solver.prototxt, I would like to w

5条回答
  •  星月不相逢
    2020-12-03 23:19

    If your network is like:

    layer {phase: TRAIN}
    layer {phase: TEST}
    layer {}
    layer {phase: TRAIN}
    layer {}
    layer {phase: TEST}
    layer {}
    layer {}
    layer {phase: TEST}
    

    Create a train net ns, Create a test net ns_test
    Now you basically have two strings str(ns.to_proto()) and str(ns_test.to_proto())
    Merge those two using python regex taking into account the required layer order.

提交回复
热议问题