Вы находитесь на странице: 1из 3

When using a CNN, the four important hyperparameters we have to decide on are:

• the kernel size


• the filter count (that is, how many filters do we want to use)
• stride (how big are the steps of the filter)
• padding

Process
Create testing data folders including subfolders with different geological phenomena
Create training data folders including subfolders with different geological phenomena

def load_data(data_directory):
Process
Create testing data folders including subfolders with different geological phenomena
Create training data folders including subfolders with different geological phenomena

“””
Step 2 – data inspection of the ndim and size attributes of the images array:
“””

# Print the `images` dimensions


print(images.ndim)

# Print the number of `images`'s elements


print(images.size)

# Print the first instance of `images`


images[0]

“””
Step 3 – data inspection of the ndim and size attributes of the labels array
“””
# Print the `labels` dimensions
print(labels.ndim)

# Print the number of `labels`'s elements


print(labels.size)

# Count the number of labels


print(len(set(labels)))
“””
Step 4 – data inspection of the distribution of the images
“””
# Import the `pyplot` module
import matplotlib.pyplot as plt

# Make a histogram with 62 bins of the `labels` data


plt.hist(labels, 62)

# Show the plot


plt.show()

“””
Step 5 – Exploratory data analysis
Review the size of the images – are they equal or unequal?
Is there an equal or unequal distribution of images – we can assign random numbers to
images?
“””

# Import the `pyplot` module as `plt`


import matplotlib.pyplot as plt

# Get the unique labels


unique_labels = set(labels)

# Initialize the figure


plt.figure(figsize=(15, 15))

# Set a counter
i = 1

# For each unique label,


for label in unique_labels:
# You pick the first image for each label
image = images[labels.index(label)]
# Define 64 subplots
plt.subplot(8, 8, i)
# Don't include axes
plt.axis('off')
# Add a title to each subplot
plt.title("Label {0} ({1})".format(label, labels.count(label)))
# Add 1 to the counter
i += 1
# And you plot this first image
plt.imshow(image)

# Show the plot


plt.show()

“””
Step 6 – Feature Extraction - classification
Note Colour matters less in classification questions. For detection questions, colour matters
bigly!
Rescale the images and convert the images that are held in the images array to grayscale
using skimage or Scikit-Image library. Use the resize() function in the transform module to
resize each image to 28 by 28 pixels. Once again, you see that the way you actually form the
list: for every image that you find in the images array, you’ll perform the transformation
operation that you borrow from the skimage library. Finally, you store the result in the
images28 variable:
“””
# Import the `transform` module from `skimage`
from skimage import transform

# Rescale the images in the `images` array


images28 = [transform.resize(image, (28, 28)) for image in images]

Вам также может понравиться