Top Related Projects
🤗 Transformers: State-of-the-art Machine Learning for Pytorch, TensorFlow, and JAX.
An Open Source Machine Learning Framework for Everyone
Tensors and Dynamic neural networks in Python with strong GPU acceleration
scikit-learn: machine learning in Python
Deep Learning for humans
DeepSpeed is a deep learning optimization library that makes distributed training and inference easy, efficient, and effective.
Quick Overview
The fastai/fastbook repository contains the draft of the book "Deep Learning for Coders with fastai and PyTorch" by Jeremy Howard and Sylvain Gugger. It provides a comprehensive guide to deep learning using the fastai library and PyTorch, with accompanying Jupyter notebooks for hands-on learning and experimentation.
Pros
- Comprehensive coverage of deep learning concepts and practical applications
- Hands-on approach with interactive Jupyter notebooks
- Based on the popular fastai library, which simplifies deep learning workflows
- Free and open-source, making it accessible to a wide audience
Cons
- May require some prior programming knowledge, particularly in Python
- Content is still in draft form, so there might be occasional errors or inconsistencies
- Focused primarily on the fastai ecosystem, which may limit exposure to other deep learning frameworks
- Large repository size due to included datasets and notebooks
Code Examples
Since this is a book repository and not a code library, there are no specific code examples to showcase. However, the book contains numerous code snippets and complete examples within its Jupyter notebooks.
Getting Started
To get started with the fastai/fastbook:
-
Clone the repository:
git clone https://github.com/fastai/fastbook.git
-
Install the required dependencies:
pip install -r requirements.txt
-
Launch Jupyter Notebook or Jupyter Lab:
jupyter notebook
or
jupyter lab
-
Navigate to the cloned repository and open the desired notebook to start learning and experimenting with the code examples provided in the book.
Competitor Comparisons
🤗 Transformers: State-of-the-art Machine Learning for Pytorch, TensorFlow, and JAX.
Pros of transformers
- Extensive library of pre-trained models for various NLP tasks
- Supports multiple deep learning frameworks (PyTorch, TensorFlow)
- Active community and frequent updates
Cons of transformers
- Steeper learning curve for beginners
- Focused primarily on NLP tasks, less versatile for general ML
Code comparison
fastbook:
from fastai.vision.all import *
path = untar_data(URLs.PETS)/'images'
def is_cat(x): return x[0].isupper()
dls = ImageDataLoaders.from_name_func(
path, get_image_files(path), valid_pct=0.2, seed=42,
label_func=is_cat, item_tfms=Resize(224))
transformers:
from transformers import AutoTokenizer, AutoModelForSequenceClassification
tokenizer = AutoTokenizer.from_pretrained("bert-base-uncased")
model = AutoModelForSequenceClassification.from_pretrained("bert-base-uncased")
inputs = tokenizer("Hello, my dog is cute", return_tensors="pt")
outputs = model(**inputs)
An Open Source Machine Learning Framework for Everyone
Pros of TensorFlow
- Extensive ecosystem with tools like TensorBoard for visualization
- Strong support for production deployment and mobile/edge devices
- Flexible low-level API for advanced customization
Cons of TensorFlow
- Steeper learning curve for beginners
- More verbose code for simple tasks
- Less focus on practical, applied machine learning techniques
Code Comparison
TensorFlow:
import tensorflow as tf
model = tf.keras.Sequential([
tf.keras.layers.Dense(64, activation='relu'),
tf.keras.layers.Dense(10, activation='softmax')
])
model.compile(optimizer='adam', loss='categorical_crossentropy')
fastai:
from fastai.vision.all import *
learn = cnn_learner(dls, resnet34, metrics=error_rate)
learn.fit_one_cycle(4)
Summary
TensorFlow offers a comprehensive ecosystem for deep learning with powerful low-level capabilities, making it suitable for complex projects and production deployment. However, it can be more challenging for beginners and requires more code for simple tasks. fastbook, on the other hand, focuses on practical machine learning techniques and provides a more user-friendly interface for quick experimentation and learning. The choice between the two depends on the specific project requirements and the user's experience level.
Tensors and Dynamic neural networks in Python with strong GPU acceleration
Pros of PyTorch
- More comprehensive and lower-level framework, offering greater flexibility and control
- Larger community and ecosystem, with more third-party libraries and resources
- Better suited for research and advanced deep learning applications
Cons of PyTorch
- Steeper learning curve, especially for beginners in deep learning
- Requires more boilerplate code for common tasks
- Less focus on high-level, easy-to-use APIs for quick prototyping
Code Comparison
PyTorch:
import torch
import torch.nn as nn
class SimpleNet(nn.Module):
def __init__(self):
super(SimpleNet, self).__init__()
self.fc = nn.Linear(10, 1)
def forward(self, x):
return self.fc(x)
fastai:
from fastai.vision.all import *
learn = cnn_learner(dls, resnet34, metrics=error_rate)
learn.fit_one_cycle(4)
Summary
PyTorch is a more powerful and flexible deep learning framework, while fastai (as demonstrated in fastbook) provides a higher-level API built on top of PyTorch, focusing on ease of use and rapid prototyping. PyTorch is better suited for advanced users and researchers, while fastai is ideal for beginners and those looking to quickly implement common deep learning tasks.
scikit-learn: machine learning in Python
Pros of scikit-learn
- Comprehensive library with a wide range of machine learning algorithms
- Well-established, mature project with extensive documentation and community support
- Designed for production use and scalability
Cons of scikit-learn
- Steeper learning curve for beginners
- Less focus on deep learning and neural networks
- May require more code for complex tasks compared to high-level APIs
Code Comparison
scikit-learn:
from sklearn.ensemble import RandomForestClassifier
from sklearn.datasets import make_classification
X, y = make_classification(n_samples=1000, n_features=4)
clf = RandomForestClassifier()
clf.fit(X, y)
fastbook:
from fastai.tabular.all import *
dls = TabularDataLoaders.from_csv('path/to/data.csv', y_names='target')
learn = tabular_learner(dls, metrics=accuracy)
learn.fit(5)
Summary
scikit-learn is a comprehensive machine learning library suitable for production environments, offering a wide range of algorithms and extensive documentation. However, it may have a steeper learning curve for beginners and requires more code for complex tasks. fastbook, on the other hand, provides a more beginner-friendly approach with high-level APIs, focusing on practical deep learning applications but may be less suitable for production environments.
Deep Learning for humans
Pros of Keras
- More extensive and mature deep learning framework with broader industry adoption
- Supports multiple backend engines (TensorFlow, Theano, CNTK)
- Larger community and ecosystem of tools, extensions, and resources
Cons of Keras
- Steeper learning curve for beginners compared to fastbook's approach
- Less focus on practical, hands-on tutorials and explanations
- May require more boilerplate code for simple tasks
Code Comparison
Keras:
from keras.models import Sequential
from keras.layers import Dense
model = Sequential([
Dense(64, activation='relu', input_shape=(10,)),
Dense(1, activation='sigmoid')
])
model.compile(optimizer='adam', loss='binary_crossentropy')
fastbook:
from fastai.tabular.all import *
learn = tabular_learner(dls, layers=[64], metrics=accuracy)
learn.fit(5)
The Keras example shows more explicit model definition and compilation, while fastbook provides a higher-level API for quick model creation and training. fastbook's approach is more concise and beginner-friendly, but Keras offers more fine-grained control over model architecture and training process.
DeepSpeed is a deep learning optimization library that makes distributed training and inference easy, efficient, and effective.
Pros of DeepSpeed
- Focuses on optimizing large-scale model training and inference
- Provides advanced distributed training capabilities
- Offers memory-efficient optimizers and techniques for handling large models
Cons of DeepSpeed
- Steeper learning curve for beginners
- Less emphasis on practical, end-to-end machine learning workflows
- Requires more setup and configuration for distributed environments
Code Comparison
DeepSpeed:
import deepspeed
model_engine, optimizer, _, _ = deepspeed.initialize(args=args,
model=model,
model_parameters=params)
for step, batch in enumerate(data_loader):
loss = model_engine(batch)
model_engine.backward(loss)
model_engine.step()
fastbook:
learn = cnn_learner(dls, resnet34, metrics=error_rate)
learn.fine_tune(5)
DeepSpeed focuses on distributed training and optimization, requiring more setup but offering advanced features for large-scale models. fastbook emphasizes simplicity and practical machine learning workflows, making it more accessible for beginners but potentially less flexible for complex distributed scenarios.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
English / Spanish / Korean / Chinese / Bengali / Indonesian / Italian / Portuguese / Vietnamese / Japanese
The fastai book
These notebooks cover an introduction to deep learning, fastai, and PyTorch. fastai is a layered API for deep learning; for more information, see the fastai paper. Everything in this repo is copyright Jeremy Howard and Sylvain Gugger, 2020 onwards. A selection of chapters is available to read online here.
The notebooks in this repo are used for a MOOC and form the basis of this book, which is currently available for purchase. It does not have the same GPL restrictions that are on this repository.
The code in the notebooks and python .py
files is covered by the GPL v3 license; see the LICENSE file for details. The remainder (including all markdown cells in the notebooks and other prose) is not licensed for any redistribution or change of format or medium, other than making copies of the notebooks or forking this repo for your own private use. No commercial or broadcast use is allowed. We are making these materials freely available to help you learn deep learning, so please respect our copyright and these restrictions.
If you see someone hosting a copy of these materials somewhere else, please let them know that their actions are not allowed and may lead to legal action. Moreover, they would be hurting the community because we're not likely to release additional materials in this way if people ignore our copyright.
Colab
Instead of cloning this repo and opening it on your machine, you can read and work with the notebooks using Google Colab. This is the recommended approach for folks who are just getting started -- there's no need to set up a Python development environment on your own machine, since you can just work directly in your web-browser.
You can open any chapter of the book in Colab by clicking on one of these links: Introduction to Jupyter | Chapter 1, Intro | Chapter 2, Production | Chapter 3, Ethics | Chapter 4, MNIST Basics | Chapter 5, Pet Breeds | Chapter 6, Multi-Category | Chapter 7, Sizing and TTA | Chapter 8, Collab | Chapter 9, Tabular | Chapter 10, NLP | Chapter 11, Mid-Level API | Chapter 12, NLP Deep-Dive | Chapter 13, Convolutions | Chapter 14, Resnet | Chapter 15, Arch Details | Chapter 16, Optimizers and Callbacks | Chapter 17, Foundations | Chapter 18, GradCAM | Chapter 19, Learner | Chapter 20, conclusion
Contributions
If you make any pull requests to this repo, then you are assigning copyright of that work to Jeremy Howard and Sylvain Gugger. (Additionally, if you are making small edits to spelling or text, please specify the name of the file and a very brief description of what you're fixing. It's difficult for reviewers to know which corrections have already been made. Thank you.)
Citations
If you wish to cite the book, you may use the following:
@book{howard2020deep,
title={Deep Learning for Coders with Fastai and Pytorch: AI Applications Without a PhD},
author={Howard, J. and Gugger, S.},
isbn={9781492045526},
url={https://books.google.no/books?id=xd6LxgEACAAJ},
year={2020},
publisher={O'Reilly Media, Incorporated}
}
Top Related Projects
🤗 Transformers: State-of-the-art Machine Learning for Pytorch, TensorFlow, and JAX.
An Open Source Machine Learning Framework for Everyone
Tensors and Dynamic neural networks in Python with strong GPU acceleration
scikit-learn: machine learning in Python
Deep Learning for humans
DeepSpeed is a deep learning optimization library that makes distributed training and inference easy, efficient, and effective.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot