Created
July 28, 2017 22:09
-
-
Save pavgup/e6e22eb6b6c3261837881b1cf8276e96 to your computer and use it in GitHub Desktop.
fast.ai lesson 1 updated files for keras 2.0.2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import division,print_function | |
import os, json | |
from glob import glob | |
import numpy as np | |
np.set_printoptions(precision=4, linewidth=100) | |
from matplotlib import pyplot as plt | |
import sys | |
sys.settrace | |
import utils; reload(utils) | |
from utils import plots | |
# As large as you can, but no larger than 64 is recommended. | |
# If you have an older or cheaper GPU, you'll run out of memory, so will have to decrease this. | |
batch_size=64 | |
# Import our class, and instantiate | |
import vgg16; reload(vgg16) | |
from vgg16 import Vgg16 | |
path = "data/dogscats/sample/" | |
vgg = Vgg16() # THIS WILL LEAD TO A SEG FAULT | |
# Grab a few images at a time for training and validation. | |
# NB: They must be in subdirectories named based on their category | |
batches = vgg.get_batches(path+'train', batch_size=batch_size) | |
val_batches = vgg.get_batches(path+'valid', batch_size=batch_size*2) | |
vgg.finetune(batches) | |
vgg.fit(batches, val_batches, nb_epoch=1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import division,print_function | |
import math, os, json, sys, re | |
import six.moves.cPickle as pickle | |
from glob import glob | |
import numpy as np | |
from matplotlib import pyplot as plt | |
from operator import itemgetter, attrgetter, methodcaller | |
from collections import OrderedDict | |
import itertools | |
from itertools import chain | |
import pandas as pd | |
import PIL | |
from PIL import Image | |
from numpy.random import random, permutation, randn, normal, uniform, choice | |
from numpy import newaxis | |
import scipy | |
from scipy import misc, ndimage | |
from scipy.ndimage.interpolation import zoom | |
from scipy.ndimage import imread | |
from sklearn.metrics import confusion_matrix | |
import bcolz | |
from sklearn.preprocessing import OneHotEncoder | |
from sklearn.manifold import TSNE | |
from IPython.lib.display import FileLink | |
import theano | |
from theano import shared, tensor as T | |
from theano.tensor.nnet import conv2d, nnet | |
from theano.tensor.signal import pool | |
import keras | |
from keras import backend as K | |
K.set_image_dim_ordering('th') | |
from keras.utils.data_utils import get_file | |
from keras.utils import np_utils | |
from keras.utils.np_utils import to_categorical | |
from keras.models import Sequential, Model | |
from keras.layers import Input, Embedding, Reshape, merge, LSTM, Bidirectional | |
from keras.layers import TimeDistributed, Activation, SimpleRNN, GRU | |
from keras.layers.core import Flatten, Dense, Dropout, Lambda | |
from keras.regularizers import l2, l1 | |
from keras.layers.normalization import BatchNormalization | |
from keras.optimizers import SGD, RMSprop, Adam | |
from keras.layers import deserialize as layer_from_config | |
from keras.metrics import categorical_crossentropy, categorical_accuracy | |
from keras.layers.convolutional import * | |
from keras.preprocessing import image, sequence | |
from keras.preprocessing.text import Tokenizer | |
from vgg16 import * | |
from vgg16bn import * | |
np.set_printoptions(precision=4, linewidth=100) | |
to_bw = np.array([0.299, 0.587, 0.114]) | |
def gray(img): | |
if K.image_dim_ordering() == 'tf': | |
return np.rollaxis(img, 0, 1).dot(to_bw) | |
else: | |
return np.rollaxis(img, 0, 3).dot(to_bw) | |
def to_plot(img): | |
if K.image_dim_ordering() == 'tf': | |
return np.rollaxis(img, 0, 1).astype(np.uint8) | |
return np.rollaxis(img, 0, 1).astype(np.uint8) | |
else: | |
return np.rollaxis(img, 0, 3).astype(np.uint8) | |
def plot(img): | |
plt.imshow(to_plot(img)) | |
def floor(x): | |
return int(math.floor(x)) | |
def ceil(x): | |
return int(math.ceil(x)) | |
def plots(ims, figsize=(12,6), rows=1, interp=False, titles=None): | |
if type(ims[0]) is np.ndarray: | |
ims = np.array(ims).astype(np.uint8) | |
if (ims.shape[-1] != 3): | |
ims = ims.transpose((0,2,3,1)) | |
f = plt.figure(figsize=figsize) | |
for i in range(len(ims)): | |
sp = f.add_subplot(rows, len(ims)//rows, i+1) | |
sp.axis('Off') | |
if titles is not None: | |
sp.set_title(titles[i], fontsize=16) | |
plt.imshow(ims[i], interpolation=None if interp else 'none') | |
def do_clip(arr, mx): | |
clipped = np.clip(arr, (1-mx)/1, mx) | |
return clipped/clipped.sum(axis=1)[:, np.newaxis] | |
def get_batches(dirname, gen=image.ImageDataGenerator(), shuffle=True, batch_size=4, class_mode='categorical', | |
target_size=(224,224)): | |
return gen.flow_from_directory(dirname, target_size=target_size, | |
class_mode=class_mode, shuffle=shuffle, batch_size=batch_size) | |
def onehot(x): | |
return to_categorical(x) | |
def wrap_config(layer): | |
return {'class_name': layer.__class__.__name__, 'config': layer.get_config()} | |
def copy_layer(layer): return layer_from_config(wrap_config(layer)) | |
def copy_layers(layers): return [copy_layer(layer) for layer in layers] | |
def copy_weights(from_layers, to_layers): | |
for from_layer,to_layer in zip(from_layers, to_layers): | |
to_layer.set_weights(from_layer.get_weights()) | |
def copy_model(m): | |
res = Sequential(copy_layers(m.layers)) | |
copy_weights(m.layers, res.layers) | |
return res | |
def insert_layer(model, new_layer, index): | |
res = Sequential() | |
for i,layer in enumerate(model.layers): | |
if i==index: res.add(new_layer) | |
copied = layer_from_config(wrap_config(layer)) | |
res.add(copied) | |
copied.set_weights(layer.get_weights()) | |
return res | |
def adjust_dropout(weights, prev_p, new_p): | |
scal = (1-prev_p)/(1-new_p) | |
return [o*scal for o in weights] | |
def get_data(path, target_size=(224,224)): | |
batches = get_batches(path, shuffle=False, batch_size=1, class_mode=None, target_size=target_size) | |
return np.concatenate([batches.next() for i in range(batches.nb_sample)]) | |
def plot_confusion_matrix(cm, classes, normalize=False, title='Confusion matrix', cmap=plt.cm.Blues): | |
""" | |
This function prints and plots the confusion matrix. | |
Normalization can be applied by setting `normalize=True`. | |
(This function is copied from the scikit docs.) | |
""" | |
plt.figure() | |
plt.imshow(cm, interpolation='nearest', cmap=cmap) | |
plt.title(title) | |
plt.colorbar() | |
tick_marks = np.arange(len(classes)) | |
plt.xticks(tick_marks, classes, rotation=45) | |
plt.yticks(tick_marks, classes) | |
if normalize: | |
cm = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis] | |
print(cm) | |
thresh = cm.max() / 2. | |
for i, j in itertools.product(range(cm.shape[0]), range(cm.shape[1])): | |
plt.text(j, i, cm[i, j], horizontalalignment="center", color="white" if cm[i, j] > thresh else "black") | |
plt.tight_layout() | |
plt.ylabel('True label') | |
plt.xlabel('Predicted label') | |
def save_array(fname, arr): | |
c=bcolz.carray(arr, rootdir=fname, mode='w') | |
c.flush() | |
def load_array(fname): | |
return bcolz.open(fname)[:] | |
def mk_size(img, r2c): | |
r,c,_ = img.shape | |
curr_r2c = r/c | |
new_r, new_c = r,c | |
if r2c>curr_r2c: | |
new_r = floor(c*r2c) | |
else: | |
new_c = floor(r/r2c) | |
arr = np.zeros((new_r, new_c, 3), dtype=np.float32) | |
r2=(new_r-r)//2 | |
c2=(new_c-c)//2 | |
arr[floor(r2):floor(r2)+r,floor(c2):floor(c2)+c] = img | |
return arr | |
def mk_square(img): | |
x,y,_ = img.shape | |
maxs = max(img.shape[:2]) | |
y2=(maxs-y)//2 | |
x2=(maxs-x)//2 | |
arr = np.zeros((maxs,maxs,3), dtype=np.float32) | |
arr[floor(x2):floor(x2)+x,floor(y2):floor(y2)+y] = img | |
return arr | |
def vgg_ft(out_dim): | |
vgg = Vgg16() | |
vgg.ft(out_dim) | |
model = vgg.model | |
return model | |
def vgg_ft_bn(out_dim): | |
vgg = Vgg16BN() | |
vgg.ft(out_dim) | |
model = vgg.model | |
return model | |
def get_classes(path): | |
batches = get_batches(path+'train', shuffle=False, batch_size=1) | |
val_batches = get_batches(path+'valid', shuffle=False, batch_size=1) | |
test_batches = get_batches(path+'test', shuffle=False, batch_size=1) | |
return (val_batches.classes, batches.classes, onehot(val_batches.classes), onehot(batches.classes), | |
val_batches.filenames, batches.filenames, test_batches.filenames) | |
def split_at(model, layer_type): | |
layers = model.layers | |
layer_idx = [index for index,layer in enumerate(layers) | |
if type(layer) is layer_type][-1] | |
return layers[:layer_idx+1], layers[layer_idx+1:] | |
class MixIterator(object): | |
def __init__(self, iters): | |
self.iters = iters | |
self.multi = type(iters) is list | |
if self.multi: | |
self.N = sum([it[0].N for it in self.iters]) | |
else: | |
self.N = sum([it.N for it in self.iters]) | |
def reset(self): | |
for it in self.iters: it.reset() | |
def __iter__(self): | |
return self | |
def next(self, *args, **kwargs): | |
if self.multi: | |
nexts = [[next(it) for it in o] for o in self.iters] | |
n0 = np.concatenate([n[0] for n in nexts]) | |
n1 = np.concatenate([n[1] for n in nexts]) | |
return (n0, n1) | |
else: | |
nexts = [next(it) for it in self.iters] | |
n0 = np.concatenate([n[0] for n in nexts]) | |
n1 = np.concatenate([n[1] for n in nexts]) | |
return (n0, n1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import division, print_function | |
import os, json | |
from glob import glob | |
import numpy as np | |
from scipy import misc, ndimage | |
from scipy.ndimage.interpolation import zoom | |
from keras import backend as K | |
K.set_image_dim_ordering('th') | |
from keras.layers.normalization import BatchNormalization | |
from keras.utils.data_utils import get_file | |
from keras.models import Sequential | |
from keras.layers.core import Flatten, Dense, Dropout, Lambda | |
from keras.layers.convolutional import Conv2D, MaxPooling2D, ZeroPadding2D | |
from keras.layers.pooling import GlobalAveragePooling2D | |
from keras.optimizers import SGD, RMSprop, Adam | |
from keras.preprocessing import image | |
# In case we are going to use the TensorFlow backend we need to explicitly set the Theano image ordering | |
from keras import backend as K | |
K.set_image_dim_ordering('th') | |
vgg_mean = np.array([123.68, 116.779, 103.939], dtype=np.float32).reshape((3,1,1)) | |
def vgg_preprocess(x): | |
""" | |
Subtracts the mean RGB value, and transposes RGB to BGR. | |
The mean RGB was computed on the image set used to train the VGG model. | |
Args: | |
x: Image array (height x width x channels) | |
Returns: | |
Image array (height x width x transposed_channels) | |
""" | |
x = x - vgg_mean | |
return x[:, ::-1] # reverse axis rgb->bgr | |
class Vgg16(): | |
""" | |
The VGG 16 Imagenet model | |
""" | |
def __init__(self): | |
self.FILE_PATH = 'http://files.fast.ai/models/' | |
self.create() | |
self.get_classes() | |
def get_classes(self): | |
""" | |
Downloads the Imagenet classes index file and loads it to self.classes. | |
The file is downloaded only if it not already in the cache. | |
""" | |
fname = 'imagenet_class_index.json' | |
fpath = get_file(fname, self.FILE_PATH+fname, cache_subdir='models') | |
with open(fpath) as f: | |
class_dict = json.load(f) | |
self.classes = [class_dict[str(i)][1] for i in range(len(class_dict))] | |
def predict(self, imgs, details=False): | |
""" | |
Predict the labels of a set of images using the VGG16 model. | |
Args: | |
imgs (ndarray) : An array of N images (size: N x width x height x channels). | |
details : ?? | |
Returns: | |
preds (np.array) : Highest confidence value of the predictions for each image. | |
idxs (np.ndarray): Class index of the predictions with the max confidence. | |
classes (list) : Class labels of the predictions with the max confidence. | |
""" | |
# predict probability of each class for each image | |
all_preds = self.model.predict(imgs) | |
# for each image get the index of the class with max probability | |
idxs = np.argmax(all_preds, axis=1) | |
# get the values of the highest probability for each image | |
preds = [all_preds[i, idxs[i]] for i in range(len(idxs))] | |
# get the label of the class with the highest probability for each image | |
classes = [self.classes[idx] for idx in idxs] | |
return np.array(preds), idxs, classes | |
def ConvBlock(self, layers, filters): | |
""" | |
Adds a specified number of ZeroPadding and Covolution layers | |
to the model, and a MaxPooling layer at the very end. | |
Args: | |
layers (int): The number of zero padded convolution layers | |
to be added to the model. | |
filters (int): The number of convolution filters to be | |
created for each layer. | |
""" | |
model = self.model | |
for i in range(layers): | |
model.add(ZeroPadding2D((1, 1))) | |
model.add(Conv2D(filters, (3, 3), activation='relu')) | |
model.add(MaxPooling2D((2, 2), strides=(2, 2))) | |
def FCBlock(self): | |
""" | |
Adds a fully connected layer of 4096 neurons to the model with a | |
Dropout of 0.5 | |
Args: None | |
Returns: None | |
""" | |
model = self.model | |
model.add(Dense(4096, activation='relu')) | |
model.add(Dropout(0.5)) | |
def create(self): | |
""" | |
Creates the VGG16 network achitecture and loads the pretrained weights. | |
Args: None | |
Returns: None | |
""" | |
model = self.model = Sequential() | |
model.add(Lambda(vgg_preprocess, input_shape=(3,224,224), output_shape=(3,224,224))) | |
self.ConvBlock(2, 64) | |
self.ConvBlock(2, 128) | |
self.ConvBlock(3, 256) | |
self.ConvBlock(3, 512) | |
self.ConvBlock(3, 512) | |
model.add(Flatten()) | |
self.FCBlock() | |
self.FCBlock() | |
model.add(Dense(1000, activation='softmax')) | |
fname = 'vgg16.h5' | |
model.load_weights(get_file(fname, self.FILE_PATH+fname, cache_subdir='models')) | |
def get_batches(self, path, gen=image.ImageDataGenerator(), shuffle=True, batch_size=8, class_mode='categorical'): | |
""" | |
Takes the path to a directory, and generates batches of augmented/normalized data. Yields batches indefinitely, in an infinite loop. | |
See Keras documentation: https://keras.io/preprocessing/image/ | |
""" | |
return gen.flow_from_directory(path, target_size=(224,224), | |
class_mode=class_mode, shuffle=shuffle, batch_size=batch_size) | |
def ft(self, num): | |
""" | |
Replace the last layer of the model with a Dense (fully connected) layer of num neurons. | |
Will also lock the weights of all layers except the new layer so that we only learn | |
weights for the last layer in subsequent training. | |
Args: | |
num (int) : Number of neurons in the Dense layer | |
Returns: | |
None | |
""" | |
model = self.model | |
model.pop() | |
for layer in model.layers: layer.trainable=False | |
model.add(Dense(num, activation='softmax')) | |
self.compile() | |
def finetune(self, batches): | |
""" | |
Modifies the original VGG16 network architecture and updates self.classes for new training data. | |
Args: | |
batches : A keras.preprocessing.image.ImageDataGenerator object. | |
See definition for get_batches(). | |
""" | |
self.ft(batches.num_class) | |
classes = list(iter(batches.class_indices)) # get a list of all the class labels | |
# batches.class_indices is a dict with the class name as key and an index as value | |
# eg. {'cats': 0, 'dogs': 1} | |
# sort the class labels by index according to batches.class_indices and update model.classes | |
for c in batches.class_indices: | |
classes[batches.class_indices[c]] = c | |
self.classes = classes | |
def compile(self, lr=0.001): | |
""" | |
Configures the model for training. | |
See Keras documentation: https://keras.io/models/model/ | |
""" | |
self.model.compile(optimizer=Adam(lr=lr), | |
loss='categorical_crossentropy', metrics=['accuracy']) | |
def fit_data(self, trn, labels, val, val_labels, epochs=1, batch_size=64): | |
""" | |
Trains the model for a fixed number of epochs (iterations on a dataset). | |
See Keras documentation: https://keras.io/models/model/ | |
""" | |
self.model.fit(trn, labels, epochs=epochs, | |
validation_data=(val, val_labels), batch_size=batch_size) | |
def fit(self, batches, val_batches, epochs=1): | |
""" | |
Fits the model on data yielded batch-by-batch by a Python generator. | |
See Keras documentation: https://keras.io/models/model/ | |
""" | |
self.model.fit_generator(batches, | |
steps_per_epoch=batches.samples//batches.batch_size, epochs=nb_epoch, | |
validation_steps=val_batches.samples//val_batches.batch_size) | |
def test(self, path, batch_size=8): | |
""" | |
Predicts the classes using the trained model on data yielded batch-by-batch. | |
Args: | |
path (string): Path to the target directory. It should contain one subdirectory | |
per class. | |
batch_size (int): The number of images to be considered in each batch. | |
Returns: | |
test_batches, numpy array(s) of predictions for the test_batches. | |
""" | |
test_batches = self.get_batches(path, shuffle=False, batch_size=batch_size, class_mode=None) | |
return test_batches, self.model.predict_generator(test_batches, test_batches.samples//test_batches.batch_size) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This code fails with the following problem:
pavan@learn:
/lesson01$ gdb python16.5) 7.11.1GNU gdb (Ubuntu 7.11.1-0ubuntu1
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
http://www.gnu.org/software/gdb/bugs/.
Find the GDB manual and other documentation resources online at:
http://www.gnu.org/software/gdb/documentation/.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from python...done.
(gdb) run test.py
Starting program: /home/pavan/anaconda2/bin/python test.py
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7fffdf7d2700 (LWP 5995)]
[New Thread 0x7fffdefd1700 (LWP 5996)]
[New Thread 0x7fffde7d0700 (LWP 5997)]
[New Thread 0x7fffddfcf700 (LWP 5998)]
[New Thread 0x7fffdd7ce700 (LWP 5999)]
[New Thread 0x7fffdcfcd700 (LWP 6000)]
[New Thread 0x7fffdc7cc700 (LWP 6001)]
[New Thread 0x7fffdbfcb700 (LWP 6002)]
[Thread 0x7fffdefd1700 (LWP 5996) exited]
[Thread 0x7fffddfcf700 (LWP 5998) exited]
[Thread 0x7fffdcfcd700 (LWP 6000) exited]
[Thread 0x7fffdd7ce700 (LWP 5999) exited]
[Thread 0x7fffde7d0700 (LWP 5997) exited]
[Thread 0x7fffdf7d2700 (LWP 5995) exited]
[Thread 0x7fffdc7cc700 (LWP 6001) exited]
[Thread 0x7fffdbfcb700 (LWP 6002) exited]
[New Thread 0x7fffdbfcb700 (LWP 6004)]
[New Thread 0x7fffdc7cc700 (LWP 6005)]
[New Thread 0x7fffdcfcd700 (LWP 6006)]
[New Thread 0x7fffdd7ce700 (LWP 6007)]
[New Thread 0x7fffdf7d2700 (LWP 6008)]
[New Thread 0x7fffdefd1700 (LWP 6009)]
[New Thread 0x7fffde7d0700 (LWP 6010)]
[New Thread 0x7fffddfcf700 (LWP 6011)]
[New Thread 0x7fffce41b700 (LWP 6012)]
[New Thread 0x7fffcdc1a700 (LWP 6013)]
[New Thread 0x7fffcd419700 (LWP 6014)]
[New Thread 0x7fffccc18700 (LWP 6015)]
[New Thread 0x7fffbad5d700 (LWP 6031)]
[New Thread 0x7fffb8f7f700 (LWP 6032)]
[New Thread 0x7fffb3fff700 (LWP 6033)]
Using cuDNN version 5110 on context None
Mapped name None to device cuda0: GeForce GTX 1080 Ti (0000:01:00.0)
Using Theano backend.
Thread 1 "python" received signal SIGSEGV, Segmentation fault.
, argc=2, argv=0x7fffffffe588, init=, fini=, rtld_fini=,0x00007fffa47f9bd8 in ?? ()
(gdb) backtrace
#0 0x00007fffa47f9bd8 in ?? ()
#1 0x00007fffc595b571 in GpuKernel_clear () from /home/pavan/anaconda2/lib/python2.7/site-packages/pygpu/../../../libgpuarray.so.2
#2 0x00007fffc595b678 in GpuKernel_init () from /home/pavan/anaconda2/lib/python2.7/site-packages/pygpu/../../../libgpuarray.so.2
#3 0x00007fffa3d8e812 in (anonymous namespace)::__struct_compiled_op_d97078c6f52397005437670429dff726::init (storage_V9=, storage_V1=,
storage_V7=, storage_V5=, storage_V3=, __ERROR=0x7fffa4832c68, this=0x1c7cae90)
at /home/pavan/.theano/compiledir_Linux-4.4--generic-x86_64-with-debian-stretch-sid-x86_64-2.7.13-64/tmpqdMsBj/mod.cpp:122
#4 instantiate (self=, argtuple=)
at /home/pavan/.theano/compiledir_Linux-4.4--generic-x86_64-with-debian-stretch-sid-x86_64-2.7.13-64/tmpqdMsBj/mod.cpp:680
#5 0x00007ffff7ad8bad in ext_do_call (nk=-1532064328, na=, flags=, pp_stack=0x7fffffffaee8, func=0x7fffa4d77c20) at Python/ceval.c:4663
#6 PyEval_EvalFrameEx (f=, throwflag=) at Python/ceval.c:3028
#7 0x00007ffff7ad9c3e in PyEval_EvalCodeEx (co=0x7fffc7e211b0, globals=, locals=, args=, argcount=5, kws=0x31a7b08,
kwcount=1, defs=0x7fffc81b4260, defcount=2, closure=0x0) at Python/ceval.c:3584
#8 0x00007ffff7ad91f7 in fast_function (nk=, na=5, n=, pp_stack=0x7fffffffb108, func=0x7fffc770b140) at Python/ceval.c:4447
#9 call_function (oparg=, pp_stack=0x7fffffffb108) at Python/ceval.c:4372
#10 PyEval_EvalFrameEx (f=, throwflag=) at Python/ceval.c:2989
#11 0x00007ffff7ad9c3e in PyEval_EvalCodeEx (co=0x7fffc7e9b6b0, globals=, locals=, args=, argcount=4, kws=0x31a7888,
kwcount=1, defs=0x7fffc76f55e8, defcount=4, closure=0x0) at Python/ceval.c:3584
#12 0x00007ffff7ad91f7 in fast_function (nk=, na=4, n=, pp_stack=0x7fffffffb328, func=0x7fffc770ac80) at Python/ceval.c:4447
#13 call_function (oparg=, pp_stack=0x7fffffffb328) at Python/ceval.c:4372
#14 PyEval_EvalFrameEx (f=, throwflag=) at Python/ceval.c:2989
#15 0x00007ffff7ad9c3e in PyEval_EvalCodeEx (co=0x7fffc7e9b7b0, globals=, locals=, args=, argcount=1, kws=0x31a6168,
kwcount=2, defs=0x7fffc7dd8a08, defcount=4, closure=0x0) at Python/ceval.c:3584
#16 0x00007ffff7ad91f7 in fast_function (nk=, na=1, n=, pp_stack=0x7fffffffb548, func=0x7fffc770ad70) at Python/ceval.c:4447
#17 call_function (oparg=, pp_stack=0x7fffffffb548) at Python/ceval.c:4372
#18 PyEval_EvalFrameEx (f=, throwflag=) at Python/ceval.c:2989
#19 0x00007ffff7ad9c3e in PyEval_EvalCodeEx (co=0x7fffc7e5c1b0, globals=, locals=, args=, argcount=5, kws=0x31a5ef0,
kwcount=0, defs=0x0, defcount=0, closure=0x0) at Python/ceval.c:3584
#20 0x00007ffff7ad91f7 in fast_function (nk=, na=5, n=, pp_stack=0x7fffffffb768, func=0x7fffc7703e60) at Python/ceval.c:4447
#21 call_function (oparg=, pp_stack=0x7fffffffb768) at Python/ceval.c:4372
#22 PyEval_EvalFrameEx (f=, throwflag=) at Python/ceval.c:2989
#23 0x00007ffff7ad9c3e in PyEval_EvalCodeEx (co=0x7fffc7e5c3b0, globals=, locals=, args=, argcount=5, kws=0x31a57c8,
kwcount=1, defs=0x7fffc7e59ce8, defcount=1, closure=0x0) at Python/ceval.c:3584
#24 0x00007ffff7ad91f7 in fast_function (nk=, na=5, n=, pp_stack=0x7fffffffb988, func=0x7fffc7703f50) at Python/ceval.c:4447
#25 call_function (oparg=, pp_stack=0x7fffffffb988) at Python/ceval.c:4372
#26 PyEval_EvalFrameEx (f=, throwflag=) at Python/ceval.c:2989
#27 0x00007ffff7ad9c3e in PyEval_EvalCodeEx (co=0x7fffc76ecab0, globals=, locals=, args=, argcount=1, kws=0x7fffba3e8bc8,
kwcount=3, defs=0x7fffc7719a08, defcount=4, closure=0x0) at Python/ceval.c:3584
#28 0x00007ffff7ad91f7 in fast_function (nk=, na=1, n=, pp_stack=0x7fffffffbba8, func=0x7fffc7675320) at Python/ceval.c:4447
#29 call_function (oparg=, pp_stack=0x7fffffffbba8) at Python/ceval.c:4372
#30 PyEval_EvalFrameEx (f=, throwflag=) at Python/ceval.c:2989
#31 0x00007ffff7ad9c3e in PyEval_EvalCodeEx (co=0x7fffc7e3ff30, globals=, locals=, args=, argcount=1, kws=0x31a5480,
kwcount=2, defs=0x7fffc9203a68, defcount=3, closure=0x0) at Python/ceval.c:3584
#32 0x00007ffff7ad91f7 in fast_function (nk=, na=1, n=, pp_stack=0x7fffffffbdc8, func=0x7fffc77096e0) at Python/ceval.c:4447
#33 call_function (oparg=, pp_stack=0x7fffffffbdc8) at Python/ceval.c:4372
#34 PyEval_EvalFrameEx (f=, throwflag=) at Python/ceval.c:2989
#35 0x00007ffff7ad9c3e in PyEval_EvalCodeEx (co=0x7fffc76df4b0, globals=, locals=, args=, argcount=2, kws=0x1c7d0c68,
kwcount=0, defs=0x7fffc76d7b58, defcount=3, closure=0x0) at Python/ceval.c:3584
#36 0x00007ffff7ad91f7 in fast_function (nk=, na=2, n=, pp_stack=0x7fffffffbfe8, func=0x7fffc76a0c08) at Python/ceval.c:4447
#37 call_function (oparg=, pp_stack=0x7fffffffbfe8) at Python/ceval.c:4372
#38 PyEval_EvalFrameEx (f=, throwflag=) at Python/ceval.c:2989
#39 0x00007ffff7ad9c3e in PyEval_EvalCodeEx (co=0x7fffc76df8b0, globals=, locals=, args=, argcount=3, kws=0x1c7cb330,
kwcount=5, defs=0x7fffc76dec98, defcount=6, closure=0x0) at Python/ceval.c:3584
#40 0x00007ffff7ad91f7 in fast_function (nk=, na=3, n=, pp_stack=0x7fffffffc208, func=0x7fffc76a0de8) at Python/ceval.c:4447
#41 call_function (oparg=, pp_stack=0x7fffffffc208) at Python/ceval.c:4372
#42 PyEval_EvalFrameEx (f=, throwflag=) at Python/ceval.c:2989
#43 0x00007ffff7ad9c3e in PyEval_EvalCodeEx (co=0x7fffc76af9b0, globals=, locals=, args=, argcount=0, kws=0x1c7cad88,
kwcount=13, defs=0x7fffc769b658, defcount=12, closure=0x0) at Python/ceval.c:3584
#44 0x00007ffff7ad91f7 in fast_function (nk=, na=0, n=, pp_stack=0x7fffffffc428, func=0x7fffc7438488) at Python/ceval.c:4447
#45 call_function (oparg=, pp_stack=0x7fffffffc428) at Python/ceval.c:4372
#46 PyEval_EvalFrameEx (f=, throwflag=) at Python/ceval.c:2989
#47 0x00007ffff7ad9c3e in PyEval_EvalCodeEx (co=0x7fffc743cab0, globals=, locals=, args=, argcount=2, kws=0x7fffa4b65fd8,
kwcount=0, defs=0x7fffc76b22a8, defcount=11, closure=0x0) at Python/ceval.c:3584
#48 0x00007ffff7ad91f7 in fast_function (nk=, na=2, n=, pp_stack=0x7fffffffc648, func=0x7fffc74527d0) at Python/ceval.c:4447
#49 call_function (oparg=, pp_stack=0x7fffffffc648) at Python/ceval.c:4372
#50 PyEval_EvalFrameEx (f=, throwflag=) at Python/ceval.c:2989
#51 0x00007ffff7ad9c3e in PyEval_EvalCodeEx (co=0x7fffc7e27eb0, globals=, locals=, args=, argcount=1, kws=0x1c7c8ea0,
kwcount=0, defs=0x7fffc7e3c868, defcount=1, closure=0x0) at Python/ceval.c:3584
#52 0x00007ffff7ad91f7 in fast_function (nk=, na=1, n=, pp_stack=0x7fffffffc868, func=0x7fffc7e43848) at Python/ceval.c:4447
---Type to continue, or q to quit---
#53 call_function (oparg=, pp_stack=0x7fffffffc868) at Python/ceval.c:4372
#54 PyEval_EvalFrameEx (f=, throwflag=) at Python/ceval.c:2989
#55 0x00007ffff7ad9c3e in PyEval_EvalCodeEx (co=0x7fffb8736a30, globals=, locals=, args=, argcount=1, kws=0x1c5eef98,
kwcount=2, defs=0x7fffb84d1770, defcount=2, closure=0x0) at Python/ceval.c:3584
#56 0x00007ffff7ad91f7 in fast_function (nk=, na=1, n=, pp_stack=0x7fffffffca88, func=0x7fffb8458c80) at Python/ceval.c:4447
#57 call_function (oparg=, pp_stack=0x7fffffffca88) at Python/ceval.c:4372
#58 PyEval_EvalFrameEx (f=, throwflag=) at Python/ceval.c:2989
#59 0x00007ffff7ad9c3e in PyEval_EvalCodeEx (co=0x7fffb8054930, globals=, locals=, args=, argcount=2, kws=0x1c5ede30,
kwcount=4, defs=0x7fffb806cab8, defcount=4, closure=0x0) at Python/ceval.c:3584
#60 0x00007ffff7ad91f7 in fast_function (nk=, na=2, n=, pp_stack=0x7fffffffcca8, func=0x7fffa5c9f578) at Python/ceval.c:4447
#61 call_function (oparg=, pp_stack=0x7fffffffcca8) at Python/ceval.c:4372
#62 PyEval_EvalFrameEx (f=, throwflag=) at Python/ceval.c:2989
#63 0x00007ffff7ad9c3e in PyEval_EvalCodeEx (co=0x7fffa4d4d430, globals=, locals=, args=, argcount=2, kws=0x1de2510,
kwcount=0, defs=0x0, defcount=0, closure=0x0) at Python/ceval.c:3584
#64 0x00007ffff7ad91f7 in fast_function (nk=, na=2, n=, pp_stack=0x7fffffffcec8, func=0x7fffa4cfec08) at Python/ceval.c:4447
#65 call_function (oparg=, pp_stack=0x7fffffffcec8) at Python/ceval.c:4372
#66 PyEval_EvalFrameEx (f=, throwflag=) at Python/ceval.c:2989
#67 0x00007ffff7ad9c3e in PyEval_EvalCodeEx (co=0x7fffb8054ab0, globals=, locals=, args=, argcount=2, kws=0x0, kwcount=0,
defs=0x0, defcount=0, closure=0x0) at Python/ceval.c:3584
#68 0x00007ffff7a54a61 in function_call (func=0x7fffa5c9f6e0, arg=0x7fffede0ac20, kw=0x0) at Objects/funcobject.c:523
#69 0x00007ffff7a24e93 in PyObject_Call (func=0x7fffa5c9f6e0, arg=, kw=) at Objects/abstract.c:2547
#70 0x00007ffff7a3764f in instancemethod_call (func=0x7fffa5c9f6e0, arg=0x7fffede0ac20, kw=0x0) at Objects/classobject.c:2602
#71 0x00007ffff7a24e93 in PyObject_Call (func=0x7fffa5085a00, arg=, kw=) at Objects/abstract.c:2547
#72 0x00007ffff7a952ac in slot_tp_call (self=0x7fffa4c283d0, args=0x7ffff7e8fe50, kwds=0x0) at Objects/typeobject.c:5546
#73 0x00007ffff7a24e93 in PyObject_Call (func=0x7fffa4c283d0, arg=, kw=) at Objects/abstract.c:2547
#74 0x00007ffff7ad780d in do_call (nk=, na=, pp_stack=0x7fffffffd4c8, func=0x7fffa4c283d0) at Python/ceval.c:4569
#75 call_function (oparg=, pp_stack=0x7fffffffd4c8) at Python/ceval.c:4374
#76 PyEval_EvalFrameEx (f=, throwflag=) at Python/ceval.c:2989
#77 0x00007ffff7ad9c3e in PyEval_EvalCodeEx (co=0x7fffb80cfa30, globals=, locals=, args=, argcount=2, kws=0x1c5d7418,
kwcount=0, defs=0x0, defcount=0, closure=0x0) at Python/ceval.c:3584
#78 0x00007ffff7ad91f7 in fast_function (nk=, na=2, n=, pp_stack=0x7fffffffd6e8, func=0x7fffa4d26e60) at Python/ceval.c:4447
#79 call_function (oparg=, pp_stack=0x7fffffffd6e8) at Python/ceval.c:4372
#80 PyEval_EvalFrameEx (f=, throwflag=) at Python/ceval.c:2989
#81 0x00007ffff7ad9c3e in PyEval_EvalCodeEx (co=0x7ffff02d3bb0, globals=, locals=, args=, argcount=3, kws=0x7fffa50c89f8,
kwcount=0, defs=0x0, defcount=0, closure=0x0) at Python/ceval.c:3584
#82 0x00007ffff7ad91f7 in fast_function (nk=, na=3, n=, pp_stack=0x7fffffffd908, func=0x7fffa4cd66e0) at Python/ceval.c:4447
#83 call_function (oparg=, pp_stack=0x7fffffffd908) at Python/ceval.c:4372
#84 PyEval_EvalFrameEx (f=, throwflag=) at Python/ceval.c:2989
#85 0x00007ffff7ad9c3e in PyEval_EvalCodeEx (co=0x7ffff02d3ab0, globals=, locals=, args=, argcount=1, kws=0x7fffa4cb7390,
kwcount=0, defs=0x0, defcount=0, closure=0x0) at Python/ceval.c:3584
#86 0x00007ffff7ad91f7 in fast_function (nk=, na=1, n=, pp_stack=0x7fffffffdb28, func=0x7fffa4cd67d0) at Python/ceval.c:4447
#87 call_function (oparg=, pp_stack=0x7fffffffdb28) at Python/ceval.c:4372
#88 PyEval_EvalFrameEx (f=, throwflag=) at Python/ceval.c:2989
#89 0x00007ffff7ad9c3e in PyEval_EvalCodeEx (co=0x7fffe2d021b0, globals=, locals=, args=, argcount=1, kws=0x0, kwcount=0,
defs=0x0, defcount=0, closure=0x0) at Python/ceval.c:3584
#90 0x00007ffff7a54a61 in function_call (func=0x7fffa4cd6578, arg=0x7ffff7e8ff50, kw=0x0) at Objects/funcobject.c:523
#91 0x00007ffff7a24e93 in PyObject_Call (func=0x7fffa4cd6578, arg=, kw=) at Objects/abstract.c:2547
#92 0x00007ffff7a3764f in instancemethod_call (func=0x7fffa4cd6578, arg=0x7ffff7e8ff50, kw=0x0) at Objects/classobject.c:2602
#93 0x00007ffff7a24e93 in PyObject_Call (func=0x7fffa4daec80, arg=, kw=) at Objects/abstract.c:2547
#94 0x00007ffff7acf7b3 in PyEval_CallObjectWithKeywords (func=0x7fffa4daec80, arg=0x7ffff7f9e050, kw=) at Python/ceval.c:4221
#95 0x00007ffff7a394e6 in PyInstance_New (klass=, arg=0x7ffff7f9e050, kw=0x0) at Objects/classobject.c:581
#96 0x00007ffff7a24e93 in PyObject_Call (func=0x7fffa4cd53f8, arg=, kw=) at Objects/abstract.c:2547
#97 0x00007ffff7ad780d in do_call (nk=, na=, pp_stack=0x7fffffffe168, func=0x7fffa4cd53f8) at Python/ceval.c:4569
#98 call_function (oparg=, pp_stack=0x7fffffffe168) at Python/ceval.c:4374
#99 PyEval_EvalFrameEx (f=, throwflag=) at Python/ceval.c:2989
#100 0x00007ffff7ad9c3e in PyEval_EvalCodeEx (co=0x7ffff7ed4930, globals=, locals=, args=, argcount=0, kws=0x0, kwcount=0,
defs=0x0, defcount=0, closure=0x0) at Python/ceval.c:3584
#101 0x00007ffff7ad9d52 in PyEval_EvalCode (co=, globals=, locals=) at Python/ceval.c:669
#102 0x00007ffff7afa450 in run_mod (arena=0x639e00, flags=0x7fffffffe460, locals=0x7ffff7f73168, globals=0x7ffff7f73168, filename=, mod=0x6a5408)
at Python/pythonrun.c:1376
#103 PyRun_FileExFlags (fp=0x69cd70, filename=, start=, globals=0x7ffff7f73168, locals=0x7ffff7f73168, closeit=1, flags=0x7fffffffe460)
at Python/pythonrun.c:1362
#104 0x00007ffff7afa62f in PyRun_SimpleFileExFlags (fp=0x69cd70, filename=0x7fffffffe7c2 "test.py", closeit=1, flags=0x7fffffffe460) at Python/pythonrun.c:948
#105 0x00007ffff7b0ffd4 in Py_Main (argc=, argv=) at Modules/main.c:645
#106 0x00007ffff6d04830 in __libc_start_main (main=0x4007f0
stack_end=0x7fffffffe578) at ../csu/libc-start.c:291
#107 0x0000000000400729 in _start ()
(gdb)