</>
Skip to content
Data Science lessons (17/42)

Data Science — Deep Learning

Neural network basics

import tensorflow as tf
from tensorflow import keras

# Build model
model = keras.Sequential([
    keras.layers.Dense(64, activation='relu', input_shape=(10,)),
    keras.layers.Dense(32, activation='relu'),
    keras.layers.Dense(1, activation='sigmoid')
])

# Compile
model.compile(optimizer='adam', loss='binary_crossentropy', metrics=['accuracy'])

Training

# Train
history = model.fit(X_train, y_train, epochs=10, validation_split=0.2)

# Evaluate
loss, accuracy = model.evaluate(X_test, y_test)

CNN for images

model = keras.Sequential([
    keras.layers.Conv2D(32, (3, 3), activation='relu', input_shape=(28, 28, 1)),
    keras.layers.MaxPooling2D((2, 2)),
    keras.layers.Conv2D(64, (3, 3), activation='relu'),
    keras.layers.Flatten(),
    keras.layers.Dense(64, activation='relu'),
    keras.layers.Dense(10, activation='softmax')
])

RNN for sequences

model = keras.Sequential([
    keras.layers.LSTM(64, return_sequences=True, input_shape=(100, 10)),
    keras.layers.LSTM(32),
    keras.layers.Dense(1)
])

Mini Practice

  1. Build a simple neural network
  2. Train on a dataset
  3. Build a CNN
  4. Create an RNN

Up Next

Continue with Computer Vision - Image analysis.

Related Topics

Frequently Asked Questions about Deep Learning

What is Deep Learning in Data Science?

Deep Learning is a fundamental concept in Data Science. This lesson explains it step by step with clear examples, making it easy for beginners to understand.

How do I learn Deep Learning?

Start by reading the explanation above, then try the code examples. Practice by modifying the examples and experimenting with different values. Hands-on practice is the best way to learn Deep Learning.

Why is Deep Learning important in Data Science?

Deep Learning is essential for Data Science development. Understanding this concept will help you write better code and solve real-world problems more effectively.