You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am a beginner using BigDL to create a ParallelTable model for training, but I encountered errors in converting between Tensor and Table types:
Caused by: java. lang. ClassCastException: com. intel. analytics. bigdl. dllib. utilities Table cannot be cast to com.intel.analytics.bigdl.dllib.tensor.Tensor.
I have used Graph (Input [Float(), Sigmoid [Float())) models before, with a loss function of MSERiterion [Float()) and training data input of DataSet [Sample [Float] (Tensor (features, Array (features. length), Tensor (Array (label), Array (1)), can work normally. But now, I am confused about this. Is there a problem with my training data type (but Sample only accepts Tensor types)? Or is there a problem with my model construction? I don't know how to solve it now, I hope to receive some help
My partial code is as follows:
val modelTask1 = Sequential()
.add(SequentialFloat
.add(Linear(200, 100))
.add(ReLUFloat))
.add(Linear(100, 1))
val modelTask2 = Sequential()
.add(SequentialFloat
.add(Linear(200, 100))
.add(ReLUFloat))
.add(Linear(100, 1))
val model = ParallelTable()
.add(modelTask1)
.add(modelTask2)
val trainData = DataSet.rdd(trainDf.rdd.map(row => {
val features = row.getAsDenseVector.toArray.map(_.toFloat)
val ctr = row.getAsDouble.toFloat
val cvr = row.getAsDouble.toFloat
Sample[Float](Tensor(features, Array(features.length)), Tensor(Array(ctr, cvr), Array(2)))
})).transform(SampleToMiniBatchFloat)
val criterion = ParallelCriterionFloat
criterion.add(MSECriterionFloat, 1.0)
criterion.add(MSECriterionFloat, 1.0)
val optimizer = Optimizer(
model = model,
dataset = trainData,
criterion = criterion
).setOptimMethod(new AdamFloat)
.setEndWhen(Trigger.maxEpoch(maxEpoch.toInt))
val trainedModel = optimizer.optimize()
The text was updated successfully, but these errors were encountered:
clare-cn
changed the title
Doubts about Tensor and Table types
Doubts about ParallelTable and ParallelCriterion
Oct 26, 2024
I am a beginner using BigDL to create a ParallelTable model for training, but I encountered errors in converting between Tensor and Table types:
Caused by: java. lang. ClassCastException: com. intel. analytics. bigdl. dllib. utilities Table cannot be cast to com.intel.analytics.bigdl.dllib.tensor.Tensor.
I have used Graph (Input [Float(), Sigmoid [Float())) models before, with a loss function of MSERiterion [Float()) and training data input of DataSet [Sample [Float] (Tensor (features, Array (features. length), Tensor (Array (label), Array (1)), can work normally. But now, I am confused about this. Is there a problem with my training data type (but Sample only accepts Tensor types)? Or is there a problem with my model construction? I don't know how to solve it now, I hope to receive some help
My partial code is as follows:
val modelTask1 = Sequential()
.add(SequentialFloat
.add(Linear(200, 100))
.add(ReLUFloat))
.add(Linear(100, 1))
val modelTask2 = Sequential()
.add(SequentialFloat
.add(Linear(200, 100))
.add(ReLUFloat))
.add(Linear(100, 1))
val model = ParallelTable()
.add(modelTask1)
.add(modelTask2)
val trainData = DataSet.rdd(trainDf.rdd.map(row => {
val features = row.getAsDenseVector.toArray.map(_.toFloat)
val ctr = row.getAsDouble.toFloat
val cvr = row.getAsDouble.toFloat
Sample[Float](Tensor(features, Array(features.length)), Tensor(Array(ctr, cvr), Array(2)))
})).transform(SampleToMiniBatchFloat)
val criterion = ParallelCriterionFloat
criterion.add(MSECriterionFloat, 1.0)
criterion.add(MSECriterionFloat, 1.0)
val optimizer = Optimizer(
model = model,
dataset = trainData,
criterion = criterion
).setOptimMethod(new AdamFloat)
.setEndWhen(Trigger.maxEpoch(maxEpoch.toInt))
val trainedModel = optimizer.optimize()
The text was updated successfully, but these errors were encountered: