The problems of function 'load()'
I saved a model z defined as follow with file name 'z.model' , then I want to load the model I trained for test. There are some problems. The model I defined: def create_model(features): with C.layers.default_options(init = C.glorot_uniform()): r = C.layers.Dense(num_output_classes, activation = None)(features) return r z = create_model(input/255.0) ... z.save("z.model") #after training
load the madel: #actually I don't know how to load the model from cntk.ops.functions import Function z = Function.load("z.model") #then create a trainer using same parameters with before
Here comes problems:
Selected GPU[0] Tesla K20m as the process wide default device.
Traceback (most recent call last):
File "test.py", line 70, in
I just want know the way I loading the model is correct?
Actually, this code comes from https://cntk.ai/pythondocs/CNTK_103B_MNIST_LogisticRegression.html to practice saving and loading models, I add the code after training model(before evaluation) as follows: z.save("z.model") z = Function.load("z.model") loss = C.cross_entropy_with_softmax(z, label) label_error = C.classification_error(z, label) learning_rate = 0.2 lr_schedule = C.learning_rate_schedule(learning_rate, C.UnitType.minibatch) learner = C.sgd(z.parameters, lr_schedule) trainer = C.Trainer(z, (loss, label_error), [learner])
This might be a model compatibility issue. Did you train your model with an older version of CNTK?
given this issue hasn't been updated for a long period. I am closing this issue. Please open a new issue if your questions hasn't been answered.