Beispiel #1
0
            protected override void createModel()
            {
                bool use_saved_model = true;

                if (use_saved_model)
                {
                    var model_path = "ch6-2.cntk.model";
                    model = CNTK.Function.Load(model_path, computeDevice);
                    var replacements = new CNTK.UnorderedMapVariableVariable()
                    {
                        { model.Placeholders()[0], x }
                    };
                    model.ReplacePlaceholders(replacements);
                }
                else
                {
                    uint numClasses    = 10000;
                    int  embedding_dim = 32;
                    int  hidden_units  = 32;
                    model = CNTK.CNTKLib.OneHotOp(x, numClass: numClasses, outputSparse: true, axis: new CNTK.Axis(0));
                    model = Util.Embedding(model, embedding_dim, computeDevice);
                    model = CNTK.CSTrainingExamples.LSTMSequenceClassifier.LSTM(model, hidden_units, hidden_units, computeDevice, "lstm");
                    model = Util.Dense(model, 1, computeDevice);
                    model = CNTK.CNTKLib.Sigmoid(model);
                }
            }
            protected override void createModel()
            {
                var model_path = "ch8-1_cntk.model";

                model = CNTK.Function.Load(model_path, computeDevice);
                var replacements = new CNTK.UnorderedMapVariableVariable()
                {
                    { model.Placeholders()[0], x }
                };

                model.ReplacePlaceholders(replacements);
                softmaxOutput = CNTK.CNTKLib.Softmax(model.Output);
            }