While using this code (to re-create):
tf 1.0.0jupyter/datascience-notebook plus tf conda-installedfrom sklearn.preprocessing import LabelEncoder
from keras.utils import np_utils
labels = ['Male', 'Female'] * 5
encoder = LabelEncoder()
encoder.fit(labels)
labels = encoder.transform(labels)
labels = np_utils.to_categorical(labels)
labels.shape
results = np.ndarray(shape=(10,2623))
tflearn.init_graph(num_cores=8, gpu_memory_fraction=0.5)
net = tflearn.input_data(shape=[None, 2623])
net = tflearn.fully_connected(net, 2, activation='softmax')
net = tflearn.regression(net, optimizer='adam', loss='categorical_crossentropy')
model = tflearn.DNN(net)
model.fit(results, labels)
I got the following error:
IndexError Traceback (most recent call last)
<ipython-input-164-dc175f8e6993> in <module>()
10
11 model = tflearn.DNN(net)
---> 12 model.fit(results, labels)
/opt/conda/lib/python3.5/site-packages/tflearn/models/dnn.py in fit(self, X_inputs, Y_targets, n_epoch, validation_set, show_metric, batch_size, shuffle, snapshot_epoch, snapshot_step, excl_trainops, validation_batch_size, run_id, callbacks)
181 # TODO: check memory impact for large data and multiple optimizers
182 feed_dict = feed_dict_builder(X_inputs, Y_targets, self.inputs,
--> 183 self.targets)
184 feed_dicts = [feed_dict for i in self.train_ops]
185 val_feed_dicts = None
/opt/conda/lib/python3.5/site-packages/tflearn/utils.py in feed_dict_builder(X, Y, net_inputs, net_targets)
287 X = [X]
288 for i, x in enumerate(X):
--> 289 feed_dict[net_inputs[i]] = x
290 else:
291 # If a dict is provided
IndexError: list index out of range
See this issue (link)
TLDR;
Restart the jupyter kernel or call tf.reset_default_graph() at the top of the cell.
Cheers, that worked! Might be good to add that to the README?
thank u @shark8me ! ur comment saved me!
annoying error, please fix it
Most helpful comment
See this issue (link)
TLDR;
Restart the jupyter kernel or call
tf.reset_default_graph()at the top of the cell.