Variable value (label) of OP(fluid.layers.cross_entropy) expected >= 0 and < 5, but got 5.
Created by: SaviorD7
Hello everyone!
I have dataset with 8 features and 1 label column. My label could be: 1 , 2 , 3 , 4 , 5. So there are 5 different values.
I defined predict layer in my Liner Regression like that:
def lr_network(self):
self.inputs = fluid.layers.data(
name='x', shape=[1, 8], dtype="float32")
self.label = fluid.layers.data(name='label', shape=[1], dtype='int64')
self.predict = fluid.layers.fc(input=self.inputs,
size=5,
act='softmax')
self.sum_cost = fluid.layers.cross_entropy(
input=self.predict, label=self.label)
self.accuracy = fluid.layers.accuracy(
input=self.predict, label=self.label)
self.loss = fluid.layers.mean(self.sum_cost)
self.startup_program = fluid.default_startup_program()
So outputs could be only in range of 5 values.
When I am starting training I ger this:
Error: Variable value (label) of OP(fluid.layers.cross_entropy) expected >= 0 and < 5, but got 5. Please check label value. at (/paddle/paddle/fluid/operators/cross_entropy_op.h:175)
[operator < cross_entropy2 > error]
Why?