Apologies! One issue is that DNA_encoder
should return a numpy object:
def DNA_encoder(seq):
'''
Complex encoding of a DNA sequence
The function returns a list of complex numbers
'''
DNA_list=list(seq)
encode_DNA={'A':'-1','T':'1','C':'-1j','G':'1j', 'R':'-1+j'} # R is an ambiguous result which could either be A or G
encoded_seq= np.array([complex(encode_DNA[base]) for base in DNA_list])
return encoded_seq
In general, there are a few areas in your code that use operations that aren’t native to numpy, which can cause type errors like what you’re seeing (for reference: Autograd ArrayBox type intermediate output from optimizer - #3 by leongfy). Let me know if this helps you debug!