Translate "Train a simple Multilayer Perceptron using TensorFlow 2" to use DL Python Network Learner


Long story short, I can’t use the Keras Network Learner so I’m trying to convert the existing workflow Train a simple Multilayer Perceptron using TensorFlow 2 to use the DL Python Network Learner node instead of the Keras Network Learner. That wf is perfect for my use case, so I don’t believe that I’ll need to change the structure in any other major way, i.e. none of the other nodes need to change, assuming they don’t need to change to support the DL Python NL.

My python skills are rudimentary, but I’ve gotten other DL Python examples to work, but not for this WF. Can somebody help update whatever values I must have incorrect? I’m assuming this should be a simplistic conversion, but can’t get it to work for whatever reason.

Here’s the basic python code I’ve attempted to use. I’ve tried a number of different combinations, but all error out for one reason or another:

> import tensorflow as tf
> from TFModel import TFModel
> from tensorflow import keras
> from tensorflow.keras import layers
> import numpy as np
> #Constants
> nr_epoch=20
> inp_hist_per=10
> # Get the input network
> model = input_network
> # Get the training data
> x_train = input_table.iloc[:,10:36].values
> y_train = input_table.iloc[:,10:36].values
> # Compile the model (Specify optimizer, loss and metrics)
> input_network.compile(optimizer='adam', loss='categorical_crossentropy')
> # Train the model
> history=, y=y_train, batch_size=32, epochs=nr_epoch,)
> print(history.history)
> # Assign the trained model to the output
> output_network = model


Hi @cybrkup,

Inside the DL Python Network Learner, you can usually execute the script and this already helps to test your python code and identify any problems. Did you try to execute/test the script? What error message are you getting?

Kind regards,

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.