In this case, the images come from the Asirra dataset functionality built into
sklearn-theano. Plots show one example of each class (cats and dogs).

"""
print(__doc__)

from sklearn_theano.datasets import fetch_asirra
from sklearn_theano.feature_extraction import OverfeatTransformer
from sklearn_theano.utils import train_test_split
from sklearn.linear_model import LogisticRegression
from sklearn.pipeline import make_pipeline
from sklearn.metrics import classification_report, accuracy_score
import matplotlib.pyplot as plt
import time

asirra = fetch_asirra(image_count=20)
X = asirra.images.astype('float32')
y = asirra.target
X_train, X_test, y_train, y_test = train_test_split(X,
                                                    y,
                                                    train_size=.6,
                                                    random_state=1999)
tf = OverfeatTransformer(output_layers=[-3])
clf = LogisticRegression()
pipe = make_pipeline(tf, clf)
t0 = time.time()
pipe.fit(X_train, y_train)
print("Total transform time")
print("====================")
print(time.time() - t0)
print()
from sklearn_theano.datasets import fetch_asirra
from sklearn_theano.feature_extraction import OverfeatTransformer
import matplotlib.pyplot as plt
import time

asirra = fetch_asirra()
X = asirra.images.astype("float32")
X = X[0:5]
y = asirra.target
all_times = []
for i in range(0, 15):
    tf = OverfeatTransformer(output_layers=[i])
    t0 = time.time()
    X_tf = tf.transform(X)
    print("Shape of layer %i output" % i)
    print(X_tf.shape)
    t_o = time.time() - t0
    all_times.append(t_o)
    print("Time for layer %i" % i, t_o)
    print()
plt.plot(all_times, marker="o")
plt.title("Runtime for input to layer X")
plt.xlabel("Layer number")
plt.ylabel("Time (seconds)")
plt.show()
In this case, the images come from the Asirra dataset functionality built into
sklearn-theano. Plots show one example of each class (cats and dogs).

"""
print(__doc__)

from sklearn_theano.datasets import fetch_asirra
from sklearn_theano.feature_extraction import OverfeatTransformer
from sklearn.linear_model import LogisticRegression
from sklearn.cross_validation import train_test_split
from sklearn.pipeline import make_pipeline
from sklearn.metrics import classification_report, accuracy_score
import matplotlib.pyplot as plt
import time

asirra = fetch_asirra(image_count=20)
X = asirra.images.astype('float32')
y = asirra.target
X_train, X_test, y_train, y_test = train_test_split(
    X, y, train_size=.6, random_state=1999)
tf = OverfeatTransformer(output_layers=[-3])
clf = LogisticRegression()
pipe = make_pipeline(tf, clf)
t0 = time.time()
pipe.fit(X_train, y_train)
print("Total transform time")
print("====================")
print(time.time() - t0)
print()
y_pred = pipe.predict(X_test)
print(classification_report(y_test, y_pred))
from sklearn_theano.datasets import fetch_asirra
from sklearn_theano.feature_extraction import OverfeatTransformer
import matplotlib.pyplot as plt
import time

asirra = fetch_asirra()
X = asirra.images.astype('float32')
X = X[0:5]
y = asirra.target
all_times = []
for i in range(0, 15):
    tf = OverfeatTransformer(output_layers=[i])
    t0 = time.time()
    X_tf = tf.transform(X)
    print("Shape of layer %i output" % i)
    print(X_tf.shape)
    t_o = time.time() - t0
    all_times.append(t_o)
    print("Time for layer %i" % i, t_o)
    print()
plt.plot(all_times, marker='o')
plt.title("Runtime for input to layer X")
plt.xlabel("Layer number")
plt.ylabel("Time (seconds)")
plt.show()