Keras.NET
Keras.NET copied to clipboard
Keras.NET on Azure Environment
Hi,
When I run Keras.NET example model in Azure environment. I received 502 server error. I published the C#.NET 4.7 MVC API application on Azure. Once of the api service run this code and thrown 502 server error. I already install python37 and install keras, tensorflow and numpy on that server. Can you help me with it?
//Load train data NDarray x = np.array(new float[,] { { 0, 0 }, { 0, 1 }, { 1, 0 }, { 1, 1 } }); NDarray y = np.array(new float[] { 0, 1, 1, 0 });
//Build sequential model var model = new Sequential(); model.Add(new Dense(32, activation: "relu", input_shape: new Shape(2))); model.Add(new Dense(64, activation: "relu")); model.Add(new Dense(1, activation: "sigmoid"));
//Compile and train model.Compile(optimizer:"sgd", loss:"binary_crossentropy", metrics: new string[] { "accuracy" }); model.Fit(x, y, batch_size: 2, epochs: 1000, verbose: 1);
//Save model and weights string json = model.ToJson(); File.WriteAllText("model.json", json); model.SaveWeight("model.h5");
//Load model and weight var loaded_model = Sequential.ModelFromJson(File.ReadAllText("model.json"));