Hi Everyone,
I ma facing an error that I couldn’t fix myself neither got anything from stackoverflow or this forum. I wanted to see if anyone else faced the same error or can help me solving this.
I am following lesson code without any changes and still getting this error:
Code:
n_hidden, n_fac, cs, vocab_size = (256, 42, 8, 86)
model=Sequential([
Embedding(vocab_size, n_fac, input_length=cs),
SimpleRNN(n_hidden, activation=‘relu’, inner_init=‘identity’),
Dense(vocab_size, activation=‘softmax’)
])
model.compile(loss = ‘sparse_categorical_crossentropy’, optimizer=Adam())
model.fit(np.stack(xs,1), y, batch_size=64, nb_epoch=8)
Error:
poch 1/8
IndexError Traceback (most recent call last)
in ()
----> 1 model.fit(np.stack(xs,1), y, batch_size=64, nb_epoch=8)
/Users/trinakarmakar/anaconda2/lib/python2.7/site-packages/keras/models.pyc in fit(self, x, y, batch_size, nb_epoch, verbose, callbacks, validation_split, validation_data, shuffle, class_weight, sample_weight, **kwargs)
650 shuffle=shuffle,
651 class_weight=class_weight,
–> 652 sample_weight=sample_weight)
653
654 def evaluate(self, x, y, batch_size=32, verbose=1,
/Users/trinakarmakar/anaconda2/lib/python2.7/site-packages/keras/engine/training.pyc in fit(self, x, y, batch_size, nb_epoch, verbose, callbacks, validation_split, validation_data, shuffle, class_weight, sample_weight, initial_epoch)
1109 val_f=val_f, val_ins=val_ins, shuffle=shuffle,
1110 callback_metrics=callback_metrics,
-> 1111 initial_epoch=initial_epoch)
1112
1113 def evaluate(self, x, y, batch_size=32, verbose=1, sample_weight=None):
/Users/trinakarmakar/anaconda2/lib/python2.7/site-packages/keras/engine/training.pyc in _fit_loop(self, f, ins, out_labels, batch_size, nb_epoch, verbose, callbacks, val_f, val_ins, shuffle, callback_metrics, initial_epoch)
824 batch_logs[‘size’] = len(batch_ids)
825 callbacks.on_batch_begin(batch_index, batch_logs)
–> 826 outs = f(ins_batch)
827 if type(outs) != list:
828 outs = [outs]
/Users/trinakarmakar/anaconda2/lib/python2.7/site-packages/keras/backend/theano_backend.pyc in call(self, inputs)
809 def call(self, inputs):
810 assert type(inputs) in {list, tuple}
–> 811 return self.function(*inputs)
812
813
/Users/trinakarmakar/anaconda2/lib/python2.7/site-packages/theano/compile/function_module.pyc in call(self, *args, **kwargs)
869 node=self.fn.nodes[self.fn.position_of_error],
870 thunk=thunk,
–> 871 storage_map=getattr(self.fn, ‘storage_map’, None))
872 else:
873 # old-style linkers raise their own exceptions
/Users/trinakarmakar/anaconda2/lib/python2.7/site-packages/theano/gof/link.pyc in raise_with_op(node, thunk, exc_info, storage_map)
312 # extra long error message in that case.
313 pass
–> 314 reraise(exc_type, exc_value, exc_trace)
315
316
/Users/trinakarmakar/anaconda2/lib/python2.7/site-packages/theano/compile/function_module.pyc in call(self, *args, **kwargs)
857 t0_fn = time.time()
858 try:
–> 859 outputs = self.fn()
860 except Exception:
861 if hasattr(self.fn, ‘position_of_error’):
/Users/trinakarmakar/anaconda2/lib/python2.7/site-packages/theano/gof/op.pyc in rval(p, i, o, n)
910 # default arguments are stored in the closure of rval
911 def rval(p=p, i=node_input_storage, o=node_output_storage, n=node):
–> 912 r = p(n, [x[0] for x in i], o)
913 for o in node.outputs:
914 compute_map[o][0] = True
/Users/trinakarmakar/anaconda2/lib/python2.7/site-packages/theano/tensor/subtensor.pyc in perform(self, node, inputs, out_)
2284
2285 if self.set_instead_of_inc:
-> 2286 out[0][inputs[2:]] = inputs[1]
2287 elif inplace_increment is not None:
2288 inplace_increment(out[0], tuple(inputs[2:]), inputs[1])
IndexError: index 94 is out of bounds for axis 1 with size 86
Apply node that caused the error: AdvancedIncSubtensor{inplace=False, set_instead_of_inc=True}(Alloc.0, TensorConstant{1}, ARange{dtype=‘int64’}.0, Elemwise{Cast{int32}}.0)
Toposort index: 77
Inputs types: [TensorType(float32, matrix), TensorType(int8, scalar), TensorType(int64, vector), TensorType(int32, vector)]
Inputs shapes: [(64, 86), (), (64,), (64,)]
Inputs strides: [(344, 4), (), (8,), (4,)]
Inputs values: [‘not shown’, array(1, dtype=int8), ‘not shown’, ‘not shown’]
Outputs clients: [[Reshape{2}(AdvancedIncSubtensor{inplace=False, set_instead_of_inc=True}.0, MakeVector{dtype=‘int64’}.0)]]
Backtrace when the node is created(use Theano flag traceback.limit=N to make it longer):
File “/Users/trinakarmakar/anaconda2/lib/python2.7/site-packages/IPython/core/interactiveshell.py”, line 2827, in run_ast_nodes
if self.run_code(code, result):
File “/Users/trinakarmakar/anaconda2/lib/python2.7/site-packages/IPython/core/interactiveshell.py”, line 2881, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File “”, line 1, in
model.compile(loss = ‘sparse_categorical_crossentropy’, optimizer=Adam())
File “/Users/trinakarmakar/anaconda2/lib/python2.7/site-packages/keras/models.py”, line 578, in compile
**kwargs)
File “/Users/trinakarmakar/anaconda2/lib/python2.7/site-packages/keras/engine/training.py”, line 604, in compile
sample_weight, mask)
File “/Users/trinakarmakar/anaconda2/lib/python2.7/site-packages/keras/engine/training.py”, line 303, in weighted
score_array = fn(y_true, y_pred)
File “/Users/trinakarmakar/anaconda2/lib/python2.7/site-packages/keras/objectives.py”, line 45, in sparse_categorical_crossentropy
return K.sparse_categorical_crossentropy(y_pred, y_true)
File “/Users/trinakarmakar/anaconda2/lib/python2.7/site-packages/keras/backend/theano_backend.py”, line 1079, in sparse_categorical_crossentropy
target = T.extra_ops.to_one_hot(target, nb_class=output.shape[-1])
HINT: Use the Theano flag ‘exception_verbosity=high’ for a debugprint and storage map footprint of this apply node.