Dear Giulio,
Thank you for your valuable information -- I really appreciate it.
I have one more question. In my current setup, the response variable is a numerical value rather than a categorical one. I've created a simple training dataset and defined a neural network accordingly. In this case, the "survived" variable consists of real numbers, and therefore, the final layer is specified as LinearLayer[1], not an ElementwiseLayer with a LogisticSigmoid activation function.
However, I'm encountering the following error message:
Specification NetEncoder[{"Function", ...}] is not compatible with port "survived", which must be a length - 1 vector of real numbers.
Do you have any suggestions for resolving this issue?
Ultimately, my goal is to develop a multilayer perceptron in which:
- the predictors include multiple categorical and multiple numerical variables, and
- the responses include multiple categorical and multiple numerical variables.
An example of MLP that handles both multiple categorical and numerical predictors and responses would be really great.
I've already reviewed the example provided at the following link:
https://community.wolfram.com/groups/-/m/t/1402774
Here are my codes:
titanicdata02 =
Dataset[{<|"class" -> "1st", "age" -> 61, "sex" -> "male",
"survived" -> 1.0|>, <|"class" -> "3rd", "age" -> 15,
"sex" -> "female", "survived" -> 1.0|>, <|"class" -> "3rd",
"age" -> 15, "sex" -> "male",
"survived" -> 2.0|>, <|"class" -> "1st", "age" -> 31,
"sex" -> "female", "survived" -> 2.0|>, <|"class" -> "3rd",
"age" -> 33, "sex" -> "male", "survived" -> 1.0|>}]
net2 = NetGraph[
{
CatenateLayer[],
LinearLayer[10],
ElementwiseLayer["SELU"],
LinearLayer[1](* final output is ?????*)
},
{
{NetPort["age"], NetPort["class"], NetPort["sex"]} -> 1,
1 -> 2 -> 3 -> 4 -> NetPort["survived"]
},
"age" -> NetEncoder[{"Function", List, 1}],
"class" -> NetEncoder[{"Class", {"1st", "2nd", "3rd"}, "UnitVector"}],
"sex" -> NetEncoder[{"Class", {"male", "female"}, "UnitVector"}],
"survived" -> NetEncoder[{"Function", List, 1}]
]