Last active
March 13, 2019 08:16
-
-
Save mick001/0782247969b1fa25795b09574d7ecf0a to your computer and use it in GitHub Desktop.
Image recognition tutorial in R using deep convolutional neural networks (MXNet package). Part 1. Full article at https://firsttimeprogrammer.blogspot.com/2016/08/image-recognition-tutorial-in-r-using.html
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
# -*- coding: utf-8 -*- | |
# Imports | |
from sklearn.datasets import fetch_olivetti_faces | |
import numpy as np | |
# Download Olivetti faces dataset | |
olivetti = fetch_olivetti_faces() | |
x = olivetti.images | |
y = olivetti.target | |
# Print info on shapes and reshape where necessary | |
print("Original x shape:", x.shape) | |
X = x.reshape((400, 4096)) | |
print("New x shape:", X.shape) | |
print("y shape", y.shape) | |
# Save the numpy arrays | |
np.savetxt("C://olivetti_X.csv", X, delimiter = ",") | |
np.savetxt("C://olivetti_y.csv", y, delimiter = ",", fmt = '%d') | |
print("\nDownloading and reshaping done!") | |
################################################################################ | |
# OUTPUT | |
################################################################################ | |
# | |
# Original x shape: (400, 64, 64) | |
# New x shape: (400, 4096) | |
# y shape (400,) | |
# | |
# Downloading and reshaping done! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for sharing the code