Troubleshooting ValueError: `validation_split` Unsupported Input Types in Keras Deep Learning Model
It seems that the input data is not in the correct format. The error message indicates that the 'validation_split' parameter is only supported for Tensors or NumPy arrays, but the input data contains integers.
One possible issue is the encoding of the labels. The 'encode_labels' function returns a list of integers, but it should return a NumPy array. Changing the 'encode_labels' function to the following should fix this issue:
def encode_labels(labels):
label_dict = {l:i for i,l in enumerate(set(labels))}
encoded_labels = [label_dict[l] for l in labels]
return np.array(encoded_labels)
Another issue is that the 'seq_to_num' function returns a list of lists, but it should return a NumPy array. Changing the 'seq_to_num' function to the following should fix this issue:
def seq_to_num(seqs):
seq_num = []
for seq in seqs:
seq_num.append([int(i) for i in seq.replace('A', '1').replace('C', '2').replace('G', '3').replace('T', '4')])
return np.array(seq_num).reshape((-1, 130, 1))
The 'reshape' method is added to the end of the function to reshape the output into the expected shape ('(-1, 130, 1)').
With these changes, the code should work correctly.
AI 优化版
原文地址:https://www.cveoy.top/t/topic/lKZX 著作权归作者所有。请勿转载和采集!