I'm using the following code to fit a simple keras model:# Prepare datax1_dat = []x2_dat = []y_dat = []cs = 3for session in Sessions_group:    session = session.split(',')    for i in xrange(0,len(session)-cs+1):        x1_dat.append(session[i])        x2_dat.append(session[i+1])        y_dat.append(session[i+2])x1_dat = np.stack(x1_dat)x2_dat = np.stack(x2_dat)y_dat = np.stack(y_dat)# Create modeln_fac = 100def embedding_input(name, n_in, n_out):    inp = Input(shape=(1,), dtype='int64', name=name)    emb = Embedding(n_in, n_out, input_length=1)(inp)    return inp, Flatten()(emb)vocab_size = len(uniqueArtifacts)x1_in, x1 = embedding_input('x1', vocab_size, n_fac)x2_in, x2 = embedding_input('x2', vocab_size, n_fac)n_hidden = 512dense_in = Dense(n_hidden, activation='relu')x1_hidden = dense_in(x1)dense_hidden = Dense(n_hidden, activation='tanh')x2_dense = dense_in(x2)hidden_2 = dense_hidden(x1_hidden)x2_hidden = merge([x2_dense, hidden_2])dense_out = Dense(vocab_size, activation='softmax')x3_out = dense_out(x2_hidden)# Fit modelmodel = Model([x1_in, x2_in], x3_out)model.compile(loss='sparse_categorical_crossentropy', optimizer=Adam())model.fit([x1_dat, x2_dat], y_dat, batch_size=10, nb_epoch=1, verbose = 1)To briefly explain it - I'm trying to predict the third item given  the first 2 items. I pass item1 and item2 through Dense layers (dense_in in the code), and merge (sum) the output and pass it through another Dense layer (dense_out in the code) to produce the output.This seemingly simple code gives me the following error when I execute the fit command:---------------------------------------------------------------------------IndexError                                Traceback (most recent call last)<ipython-input-31-1912702bd26c> in <module>()----> 1 model.fit([x1_dat, x2_dat], y_dat, batch_size=10, nb_epoch=1, verbose = 1)/home/prateek/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)   1194                               val_f=val_f, val_ins=val_ins, shuffle=shuffle,   1195                               callback_metrics=callback_metrics,-> 1196                               initial_epoch=initial_epoch)   1197    1198     def evaluate(self, x, y, batch_size=32, verbose=1, sample_weight=None):/home/prateek/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)    889                 batch_logs['size'] = len(batch_ids)    890                 callbacks.on_batch_begin(batch_index, batch_logs)--> 891                 outs = f(ins_batch)    892                 if not isinstance(outs, list):    893                     outs = [outs]/home/prateek/anaconda2/lib/python2.7/site-packages/keras/backend/theano_backend.pyc in __call__(self, inputs)    957     def __call__(self, inputs):    958         assert isinstance(inputs, (list, tuple))--> 959         return self.function(*inputs)    960     961 /home/prateek/anaconda2/lib/python2.7/site-packages/theano/compile/function_module.pyc in __call__(self, *args, **kwargs)    896                     node=self.fn.nodes[self.fn.position_of_error],    897                     thunk=thunk,--> 898                     storage_map=getattr(self.fn, 'storage_map', None))    899             else:    900                 # old-style linkers raise their own exceptions/home/prateek/anaconda2/lib/python2.7/site-packages/theano/gof/link.pyc in raise_with_op(node, thunk, exc_info, storage_map)    323         # extra long error message in that case.    324         pass--> 325     reraise(exc_type, exc_value, exc_trace)    326     327 /home/prateek/anaconda2/lib/python2.7/site-packages/theano/compile/function_module.pyc in __call__(self, *args, **kwargs)    882         try:    883             outputs =\--> 884                 self.fn() if output_subset is None else\    885                 self.fn(output_subset=output_subset)    886         except Exception:/home/prateek/anaconda2/lib/python2.7/site-packages/theano/gof/op.pyc in rval(p, i, o, n)    870             # default arguments are stored in the closure of `rval`    871             def rval(p=p, i=node_input_storage, o=node_output_storage, n=node):--> 872                 r = p(n, [x[0] for x in i], o)    873                 for o in node.outputs:    874                     compute_map[o][0] = True/home/prateek/anaconda2/lib/python2.7/site-packages/theano/tensor/subtensor.pyc in perform(self, node, inputs, out_)   2240    2241         if self.set_instead_of_inc:-> 2242             out[0][inputs[2:]] = inputs[1]   2243         elif config.cxx:   2244             inplace_increment(out[0], tuple(inputs[2:]), inputs[1])IndexError: index 1864798 is out of bounds for axis 1 with size 2392Apply 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: 69Inputs types: [TensorType(float32, matrix), TensorType(int8, scalar), TensorType(int64, vector), TensorType(int32, vector)]Inputs shapes: [(10, 2392), (), (10,), (10,)]Inputs strides: [(9568, 4), (), (8,), (4,)]Inputs values: ['not shown', array(1, dtype=int8), 'not shown', 'not shown']Outputs clients: [[GpuFromHost(AdvancedIncSubtensor{inplace=False,  set_instead_of_inc=True}.0)]]Backtrace when the node is created(use Theano flag traceback.limit=N to make it longer):  File /home/prateek/anaconda2/lib/python2.7/site-packages/IPython/core/interactiveshell.py, line 2717, in run_cell    interactivity=interactivity, compiler=compiler, result=result)  File /home/prateek/anaconda2/lib/python2.7/site-packages/IPython/core/interactiveshell.py, line 2827, in run_ast_nodes    if self.run_code(code, result):  File /home/prateek/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 <ipython-input-29-6ef574590fa0>, line 1, in <module>    model.compile(loss='sparse_categorical_crossentropy', optimizer=Adam())  File /home/prateek/anaconda2/lib/python2.7/site-packages/keras/engine/training.py, line 667, in compile    sample_weight, mask)  File /home/prateek/anaconda2/lib/python2.7/site-packages/keras/engine/training.py, line 318, in weighted    score_array = fn(y_true, y_pred)  File /home/prateek/anaconda2/lib/python2.7/site-packages/keras/objectives.py, line 41, in sparse_categorical_crossentropy    return K.sparse_categorical_crossentropy(y_pred, y_true)  File /home/prateek/anaconda2/lib/python2.7/site-packages/keras/backend/theano_backend.py, line 1249, 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.Further information:The total number of values that I'm trying to predict from is 2392.The index in the error IndexError: index 1864798 is out of bounds for axis 1 with size 2392 (1864798 in this case) keeps changing as I re-execute the code.The output to the following code (the size of my data):x1_dat.shape, x2_dat.shape, y_dat.shapeis:((6510,), (6510,), (6510,))How do I go about resolving this error? Any help would be much appreciated.
Index error in simple keras model
deep learning;keras