Closed Ishitori closed 1 year ago
Three problems of your code:
zy = ZLayer.Dense(2)(merged)
to zy = ZLayer.Dense(1)(merged)
I will look into them.
I have update https://github.com/intel-analytics/BigDL/blob/main/docs/readthedocs/source/doc/DLlib/Overview/nnframes.md, the related wiki page will be updated tomorrow.
Please notice BinaryCrossEntropy's label is 0 or 1, the last layer is Dense(1) SparseCategoricalCrossEntropy is for multi label 0 until n, the last layer is Dense(n).
Could you explain me how feature_preprocessing works? As far as I understand array like [[1], [2]] means "Use feature with index 1 as the first input, and feature with inidices 2 and 3 as the second input" (so each number is the length of the features per input, and they are linearly ordered). But what [2, 2]
in [[1], [2], [2, 2]]
means? How does it get converted into LSTM input?
It still doesn't work for me though. This time it is: Caused by: org.apache.spark.SparkException: Job aborted due to stage failure: Task 0 in stage 15.0 failed 5 times, most recent failure: Lost task 0.4 in stage 15.0 (TID 5038) (ip-10-103-48-182.ec2.internal executor 7): java.lang.ArithmeticException: / by zero
[2, 2] means convert a 2 * 2 features(indices 4,5,6,7) to a Tensor of size [2, 2].
[[1], [2], [2, 2]]
correspond to the model's inputs
x1 = Input(shape=(1,))
x2 = Input(shape=(2,))
x3 = Input(shape=(2, 2,))
x3 need an input tensor of size [2, 2].
java.lang.ArithmeticException: / by zero
: is this expection thrown from ClassNllCriterion? It looks like your label is not match.
If you are using BinaryCrossEntropy, your should change the labels from 1 or 2 to 0 or 1.
df = spark.createDataFrame(
[(1, 35, 109.0, Vectors.dense([2.0, 5.0, 0.5, 0.5]), 1.0),
(2, 58, 2998.0, Vectors.dense([4.0, 10.0, 0.5, 0.5]), 2.0),
(3, 18, 123.0, Vectors.dense([3.0, 15.0, 0.5, 0.5]), 1.0)],
["user", "age", "income", "history", "label"])
Yes, it works! It is a bit confusing with the difference between different criterions that some expects a label to be 0 and 1 while others expect labels to be 1 and 2. But it is okay.
So, the last question I have about this is it possible to use multi-inputs with MKLDnn? I assume that it will speed up training by a lot!
Thank you.
Yes, it works! It is a bit confusing with the difference between different criterions that some expects a label to be 0 and 1 while others expect labels to be 1 and 2. But it is okay.
So, the last question I have about this is it possible to use multi-inputs with MKLDnn? I assume that it will speed up training by a lot!
Thank you.
It's possible to use MKLDnn, but we just provide limited support for MKLDnn now. Dllib's MKLDNN only support a few modules like Linear(Dense), Maxpooling, Convolution and BatchNormalization, etc. https://github.com/intel-analytics/BigDL/tree/main/scala/dllib/src/main/scala/com/intel/analytics/bigdl/dllib/nn/mkldnn If all the modules in your model are supported, MKLDNN will get a good performance. If some modules are not supported, the performance may be worse, the model has to waste a lot of time by converting the internal data between MKLDnn type and normal type.
Got it, thank you!
I am trying to write a simple multi inputs example based on the example from the doc, but using only core features of BigDL. Here is the code:
Unfortunately, it fails with the following exception:
It feels to me that input preprocessor fails, and instead of generating 2 inputs (one for each root) it generates only one. Or am I missing something?
Thank you.