Stacked Autoencoders. | Towards Data Science
Stacked Autoencoders. | Towards Data Science
DATA SCIENCE
Stacked Autoencoders.
Extract important features from data using deep
learning.
Rajas Bakshi
Jun 28, 2021 6 min read
Dimensionality reduction
While solving a Data Science problem, did you ever come across a
dataset with hundreds of features? or perhaps a thousand features?
If no, then you don’t know how challenging it can be to develop an
e!cient model. Dimensionality reduction for those who don’t know
is an approach to filter the essential features from the data.
Having more input features in the data makes the task of predicting
the dependent feature challenging. A large number of elements can
sometimes cause the model to have poor performance. The cause
behind this could be the model may try to find the relation between
the feature vector and output vector that is very weak or
nonexistent. There are various methods used for reducing the
dimensions of the data, and a comprehensive guide on the same can
be found on the link below.
https://www.analyticsvidhya.com/blog/2018/08/dimensionality-
reduction-techniques-python/
https://towardsdatascience.com/a-one-stop-shop-for-principal-
component-analysis-5582fb7e0a9c
Autoencoder
Stacked Autoencoder
Image by author
I know it isn’t easy to see a lot in this image. However, we can still
see a few features in the picture. The bright white shot
approximately at (0,15) is the peak seen in the FFT of the vibration
signal.
batch_size = 32
#Input Layer
encoder = Dense (2000, activation="relu", activity_regularizer=regularizers.l1(learning_rate))(in
activity_regularizer=regularizers.l1(learning_rate))(encoder)
# Code layer
# Output Layer
As we see, the FFT signal has 4000 data points; thus, our input and
output layers have 4000 neurons. When we go deep into the
network, subsequently, the number of neurons decreases. Finally, at
the code layer, we have only 200 neurons. Thus this autoencoder
tries to reduce the number of features from 4000 to 200.
Now, we build the model, compile it and fit it on our training data.
As the autoencoder’s target output is the same as the input, we
pass x_train as both inputs as well as output.
autoencoder_1.compile(metrics=['accuracy'],loss='mean_squared_error',optimizer='adam')
autoencoder_2_input = autoencoder_1.predict(x_train)
autoencoder_2.compile(metrics=['accuracy'],loss='mean_squared_error',optimizer='adam')
autoencoder_3_input = autoencoder_2.predict(autoencoder_2_input)
And now, lastly, we train our third autoencoder. As we did for the
last two encoders, we build, compile and train on our new data.
Image by author
· · ·
WRITTEN BY
Rajas Bakshi
See all from Rajas Bakshi
Topics:
Related Articles
Your home for data science and Al. The world’s leading Your email*
publication for data science, data analytics, data engineering,
First name*
machine learning, and artificial intelligence professionals.
Job title*
Job level*
Please Select
Company name*
Subscribe Now