You are doing a classification problem as I understand. CrossEntropy loss will convert each  target value in one hot vector ranging  to 7(one hot vector conversion is done by framework on its own).
So to calculate loss you need your network to output values as a vector contaning 8 values .
As in labels/target contain–
eg-[1 0 0 0 0 0 0 0] represents 0 and -[0 0 0 0 1 0 0 0] represents 4 and cross entropy will then calculate loss one by one.
Thats why  it gives error when your network will output single value . As it cannot able to compare single by network to 8 values(one hot) in target.