Hi,
I am reading a file includes class labels that are 0 and 1 and I want to convert it to long tensor to use CrossEntropy by the code below:
def read_labels(filename):
lists = deque()
with open(filename, 'r') as input_file:
lines_cache = input_file.readlines()
for current_line in lines_cache:
sp = current_line.split()
sp = map(float, sp)
sp = list(sp)
lists.append(sp)
current_label_array = np.array(lists)
return current_label_array
current_label = read_labels('./train/labels1.txt')
current_label = torch.as_tensor(current_label, dtype=torch.long, device=torch.device("cuda:0"))
but I receive this error. How could I do it?
TypeError: can't convert np.ndarray of type numpy.object_. The only supported types are: float64, float32, float16, int64, int32, int16, int8, and uint8.
Thanks