Skip to content

Instantly share code, notes, and snippets.

Pedro Marcelino pmarcelino

Block or report user

Report or block pmarcelino

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@pmarcelino
pmarcelino / sol_03_svm
Created Oct 22, 2018
SVM solution for the Dogs vs. Cats competition
View sol_03_svm
# Build model
import sklearn
from sklearn.cross_validation import train_test_split
from sklearn.grid_search import GridSearchCV
from sklearn.svm import LinearSVC
X_train, y_train = svm_features.reshape(300,7*7*512), svm_labels
param = [{
"C": [0.01, 0.1, 1, 10, 100]
@pmarcelino
pmarcelino / svm_data_concatenation
Created Oct 22, 2018
Concatenation of data for the SVM classifier
View svm_data_concatenation
# Concatenate training and validation sets
svm_features = np.concatenate((train_features, validation_features))
svm_labels = np.concatenate((train_labels, validation_labels))
@pmarcelino
pmarcelino / sol_02_global_average_pooling
Last active Oct 22, 2018
Global average pooling solution for Dogs vs. Cats
View sol_02_global_average_pooling
# Define model
from keras import models
from keras import layers
from keras import optimizers
epochs = 100
model = models.Sequential()
model.add(layers.GlobalAveragePooling2D(input_shape=(7,7,512)))
model.add(layers.Dense(1, activation='sigmoid'))
@pmarcelino
pmarcelino / sol_01_fullyConnected
Created Oct 22, 2018
Fully connected layers solution for Dogs vs. Cats
View sol_01_fullyConnected
# Define model
from keras import models
from keras import layers
from keras import optimizers
epochs = 100
model = models.Sequential()
model.add(layers.Flatten(input_shape=(7,7,512)))
model.add(layers.Dense(256, activation='relu', input_dim=(7*7*512)))
@pmarcelino
pmarcelino / extract_features
Created Oct 14, 2018
Extract features from convolutional base on Dogs vs. Cats Kaggle competition
View extract_features
# Extract features
import os, shutil
from keras.preprocessing.image import ImageDataGenerator
datagen = ImageDataGenerator(rescale=1./255)
batch_size = 32
def extract_features(directory, sample_count):
features = np.zeros(shape=(sample_count, 7, 7, 512)) # Must be equal to the output of the convolutional base
labels = np.zeros(shape=(sample_count))
@pmarcelino
pmarcelino / data_preparation
Last active Oct 14, 2018
Data preparation for Dogs vs. Cats
View data_preparation
# Create smaller dataset for Dogs vs. Cats
import os, shutil
original_dataset_dir = '/Users/macbook/dogs_cats_dataset/train/'
base_dir = '/Users/macbook/book/dogs_cats/data'
if not os.path.exists(base_dir):
os.mkdir(base_dir)
# Create directories
View dropout.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View data_augmentation.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View data_cleaning_missing_data.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View data_cleaning_missing_data
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Missing Data"
]
},
{
You can’t perform that action at this time.