зеркало из https://github.com/microsoft/MMdnn.git
2
ImportError caused by customed layer
namizzz редактировал(а) эту страницу 2018-09-22 11:10:22 +08:00
PyTorch :
https://github.com/Microsoft/MMdnn/issues/241
https://github.com/Microsoft/MMdnn/issues/281
Keras :
from keras.models import load_model
from your_custom_layer import your_custom_layer1, your_custom_layer2, your_custom_layer3
from mmdnn.conversion.keras.keras2_parser import Keras2Parser
def load_custom_model(modelPath):
model = load_model(modelPath, custom_objects={
'custom1': your_custom_layer1,
'custom2': your_custom_layer2,
'custom3': your_custom_layer3})
return model
if __name__ == '__main__':
model = load_custom_model("./model.h5")
print(model.summary())
parser = Keras2Parser(model)
parser.run('custom')