python - ValueError: could not broadcast input array from shape -


i using seq2seq model hindi english text translation. not familiar keras or deep learning. while exploring seq2seq model came across example.

https://github.com/karimkhanp/seq2seq/blob/master/seq2seq/seq2seq.py

while running program error

valueerror: not broadcast input array shape (6) shape (1,10) 

at line

temp[0:len(seq)] = seq 

error log -

[[4000, 4000, 4000, 4000, 4000, 4000]]  traceback (most recent call last):   file "seq2seq.py", line 92, in <module>     seq2seq.encode()   file "seq2seq.py", line 58, in encode     temp[0:len(seq)] = seq valueerror: not broadcast input array shape (6) shape (1,10) 

code:

def encode(self):     #encodes input sentence fixed length vector     #print("enter sentence in hindi")     inp = raw_input().decode("utf-8")     tokens = inp.split()     seq = []     token in tokens:         if token in self.proproces.vocab_tar:             seq.append(self.proproces.vocab_tar[token])         else:             token = "unk"             seq.append(self.proproces.vocab_tar[token])     #seq = map(lambda x:self.proproces.vocab_hind[x], tokens)     # normalize seq maxlen     x = []     x.append(seq)     print(x)     temp = pad_sequences(x, maxlen=self.maxlen)     temp[0:len(seq)] = seq     print(len(temp))     temp = np.asarray(temp).reshape(128,)     print(temp.shape)     prob = model.predict_on_batch(temp)#, batch_size=1, verbose=0)     translated = self.decode(prob)     print("tranlated is", translated) 

where dimention mismatch.

original code had temp = sequence.pad_sequences(x, maxlen=self.maxlen) converted temp = pad_sequences(x, maxlen=self.maxlen)


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -