Use this file to discover Exa products, pricing, evaluations, comparisons, use cases, agent interfaces, and technical documentation before exploring further.
Python deep learning libraries define neural networks, compute their gradients, and train them on GPUs and other accelerators. These libraries train and run the models behind language, vision, and speech features in apps.
Popularity
PyTorch has the most monthly downloads in this comparison, at 59.4M.
Downloads: PyPI, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.
Libraries and code examples
Transformers
Transformers defines model architectures for text, vision, audio, video, and multimodal tasks, and loads pretrained weights for them from the Hugging Face Hub. pipeline wraps a model and its preprocessing into one call for a task such as text classification or zero-shot classification. Training frameworks and inference engines such as vLLM reuse the same model definitions. The library runs on PyTorch.
Downloads / mo
119.8M
Stars
169.2K
Last release
5.23.0
License
Apache 2.0 License
Strengths
Models by name.A task and a model name from the Hub are enough for pipeline to download and run a model.
Limitations
Weights download on first use.Each model fetches its weights the first time it loads, and large models need a GPU with enough memory to hold them.
def run(self, text: str) -> dict[str, str]:
"""
Routes the text strings to different connections based on a category label.
:param text: A string of text to route.
:returns:
A dictionary with the label as key and the text as value.
:raises TypeError:
If the input is not a str.
:raises RuntimeError:
If the pipeline has not been loaded because warm_up() was not called before.
"""
if self.pipeline is None:
raise RuntimeError(
"The component TransformersZeroShotTextRouter wasn't warmed up. Run 'warm_up()' before calling 'run()'."
)
if not isinstance(text, str):
raise TypeError("TransformersZeroShotTextRouter expects a str as input.")
prediction = self.pipeline([text], candidate_labels=self.labels, multi_label=self.multi_label)
predicted_scores = prediction[0]["scores"]
max_score_index = max(range(len(predicted_scores)), key=predicted_scores.__getitem__)
label = prediction[0]["labels"][max_score_index]
return {label: text}
PyTorch
PyTorch provides tensors, arrays that compute on GPUs as well as CPUs, and neural networks built on a tape-based autograd system. The tape records operations as Python code runs, so a model's structure can change from one input to the next, and backward() computes the gradients. torch.nn supplies layers and losses, and DistributedDataParallel synchronizes gradients across training processes. Extensions can reuse NumPy, SciPy, and Cython code.
Downloads / mo
59.7M
Stars
105.7K
Last release
2.15.0
License
Apache-2.0 AND Apache-2.0 WITH LLVM-exception AND BSD-2-Clause AND BSD-3-Clause AND BSL-1.0 AND ISC AND MIT AND Zlib
Strengths
Builds dynamic autograd networks.Build neural networks on a tape-based automatic differentiation system.
Synchronizes distributed training gradients.Use DistributedDataParallel to synchronize gradients across training processes.
Limitations
Saved weights need the model class.A state dictionary holds weights only, so loading one requires the model class defined in code first.
JAX is a library for array computation and program transformation, with an API modeled on NumPy. jax.grad differentiates a Python function, including its loops, branches, and recursion, and jax.jit compiles it with XLA for GPUs and TPUs. The transformations compose, so a compiled function can also be differentiated. Neural network layers come from libraries built on JAX, such as Flax and Equinox.
Downloads / mo
12.6M
Stars
36.6K
Last release
0.12.1
License
Apache-2.0
Strengths
Composes gradients with compilation.Compile and differentiate pure Python numerical functions.
Partitions array computations across devices.Shard arrays and partition computations across multiple devices.
Limitations
Pure functions only.Transformed functions keep no hidden state, so state passes in as arguments and comes back as return values.
Research project.Google describes JAX as a research project rather than an official product, and its docs list sharp edges.
TensorFlow is an open source platform for machine learning, first developed at Google Brain. Tensors and variables compute on CPUs, GPUs, and TPUs, and tf.GradientTape records the operations inside its block to compute gradients. Distribution strategies spread existing training code across GPUs, machines, or TPUs. Stable APIs cover Python and C++.
Downloads / mo
12.4M
Stars
201.6K
Last release
2.21.0
License
Apache-2.0
Strengths
Trains with automatic gradients.Use GradientTape to compute derivatives for training.
Distributes existing training code.Use distribution strategies across GPUs, machines, or TPUs.
Limitations
Windows GPU training needs WSL.GPU builds on Windows run inside WSL, the Windows Subsystem for Linux.
def gaussian_blur(image, kernel_size, sigma, padding='SAME'):
"""Blurs the given image with separable convolution.
Args:
image: Tensor of shape [height, width, channels] and dtype float to blur.
kernel_size: Integer Tensor for the size of the blur kernel. This is should
be an odd number. If it is an even number, the actual kernel size will be
size + 1.
sigma: Sigma value for gaussian operator.
padding: Padding to use for the convolution. Typically 'SAME' or 'VALID'.
Returns:
A Tensor representing the blurred image.
"""
radius = tf.cast(kernel_size / 2, dtype=tf.int32)
kernel_size = radius * 2 + 1
x = tf.cast(tf.range(-radius, radius + 1), dtype=tf.float32)
blur_filter = tf.exp(-tf.pow(x, 2.0) /
(2.0 * tf.pow(tf.cast(sigma, dtype=tf.float32), 2.0)))
blur_filter /= tf.reduce_sum(blur_filter)
# One vertical and one horizontal filter. blur_v = tf.reshape(blur_filter, [kernel_size, 1, 1, 1])
blur_h = tf.reshape(blur_filter, [1, kernel_size, 1, 1])
num_channels = tf.shape(image)[-1]
blur_h = tf.tile(blur_h, [1, 1, num_channels, 1])
blur_v = tf.tile(blur_v, [1, 1, num_channels, 1])
expand_batch_dim = image.shape.ndims == 3
if expand_batch_dim:
# Tensorflow requires batched input to convolutions, which we can fake with # an extra dimension. image = tf.expand_dims(image, axis=0)
blurred = tf.nn.depthwise_conv2d(
image, blur_h, strides=[1, 1, 1, 1], padding=padding)
blurred = tf.nn.depthwise_conv2d(
blurred, blur_v, strides=[1, 1, 1, 1], padding=padding)
if expand_batch_dim:
blurred = tf.squeeze(blurred, axis=0)
return blurred
Keras
Keras is a high-level API for building and training deep learning models on JAX, TensorFlow, or PyTorch, with OpenVINO available for inference only. A model is a stack of layers, as in keras.Sequential, and the KERAS_BACKEND environment variable selects the engine. The keras package holds the current version, and the previous version remains available as tf-keras.
Downloads / mo
12.0M
Stars
64.4K
Last release
3.15.1
License
Apache-2.0
Strengths
Offers multiple training backends.Train through JAX, TensorFlow, or PyTorch backends.
Provides a high-level modeling API.Build and train models across vision, language, audio, and forecasting tasks.
Limitations
Backend installed separately.Keras needs TensorFlow, JAX, or PyTorch installed alongside it.
OpenVINO runs inference only.Training needs the JAX, TensorFlow, or PyTorch backend.
def call(self, inputs):
concat_inputs = []
for input_ in inputs:
if input_ in CATEGORICAL_FEATURES_WITH_VOCABULARY:
max_index = self.embeddings[input_].input_dim - 1 # Clamp the indices
# torch had some index errors during embedding hence the clip function embedded_feature = self.embeddings[input_](
keras.ops.clip(inputs[input_], 0, max_index)
)
concat_inputs.append(embedded_feature)
else:
# Project the numeric feature to encoding_size using linear transformation. proj_feature = keras.ops.expand_dims(inputs[input_], -1)
proj_feature = self.proj_layer[input_](proj_feature)
concat_inputs.append(proj_feature)
v = layers.concatenate(concat_inputs)
v = self.grn_concat(v)
v = keras.ops.expand_dims(self.softmax(v), axis=-1)
x = []
for idx, input in enumerate(concat_inputs):
x.append(self.grns[idx](input))
x = keras.ops.stack(x, axis=1)
return keras.ops.squeeze(
keras.ops.matmul(keras.ops.transpose(v, axes=[0, 2, 1]), x), axis=1
)
PyTorch Lightning
PyTorch Lightning organizes PyTorch code so that the library handles the training loop, backpropagation, mixed precision, and multi-GPU or distributed training. Model code goes in a LightningModule, and a Trainer runs it on anything from a CPU to several GPU nodes without changes to that code. Lightning Fabric offers the same scaling while the program keeps its own training loop.
Downloads / mo
11.6M
Stars
31.4K
Last release
2.6.6
License
Apache-2.0
Strengths
Training loop included.The Trainer runs training and prediction, with logging and checkpoints as options.
Limitations
Code follows its structure.Model code moves into LightningModule methods instead of a plain PyTorch loop.
Flax is a neural network library for JAX. Its current API, Flax NNX, defines models as regular Python objects with mutable state and shared references, and layers such as nnx.Linear draw their random keys from nnx.Rngs. Models built this way pass through JAX transformations for compilation and gradients. The older Linen API keeps its own documentation site.
Downloads / mo
2.7M
Stars
7.4K
Last release
0.12.12
License
Apache-2.0
Strengths
Models as Python objects.Flax NNX models are regular Python objects that can share references and change in place.
Training utilities included.Checkpointing, serialization, metrics, and on-device prefetching come with the library.
Limitations
Two APIs.Code written for Linen differs from NNX code, and the docs include a guide for moving between them.
@nn.compact
def __call__(self, x, deterministic=True):
"""Applies Transformer MlpBlock module."""
inits = dict(
kernel_init=nn.initializers.xavier_uniform(),
bias_init=nn.initializers.normal(stddev=1e-6),
)
d = x.shape[-1]
x = nn.Dense(self.mlp_dim or 4 * d, dtype=self.dtype_mm, **inits)(x)
# In some extreme batch-size cases, this is needed as of Sept 2024: x = nn.with_logical_constraint(x, ("act_batch", "act_len", "act_emb"))
x = nn.gelu(x)
x = nn.Dropout(rate=self.dropout)(x, deterministic)
x = nn.Dense(d, dtype=self.dtype_mm, **inits)(x)
return x
Equinox
Equinox is a JAX library for neural networks and for utilities that core JAX lacks, such as filtered transformations, PyTree manipulation, and runtime errors. Models subclass eqx.Module with PyTorch-like syntax, and each model is a PyTree, the nested container type JAX transforms, so it passes through jax.jit and jax.grad directly. Equinox models work with the rest of the JAX ecosystem.
Downloads / mo
1.7M
Stars
3.0K
Last release
0.13.8
License
Apache-2.0
Strengths
Models are PyTrees.Models cross compilation and gradient boundaries like any other JAX data.
Limitations
Explicit random keys.Each layer takes a random key when it is built, passed by the program.
@eqx.filter_jit
def step(
params: PyTree,
*args,
optimizer: optax.GradientTransformation,
opt_state: PyTree,
loss_fn: Callable[..., Scalar],
**kwargs,
):
"""Carry out a training step.
Args:
params: Parameters for the model
*args: Arguments passed to the loss function (often the static components
of the model).
optimizer: Optax optimizer.
opt_state: Optimizer state.
loss_fn: The loss function. This should take params and static as the first two
arguments.
**kwargs: Key word arguments passed to the loss function.
Returns:
tuple: (params, opt_state, loss_val)
"""
loss_val, grads = eqx.filter_value_and_grad(loss_fn)(
params,
*args,
**kwargs,
)
updates, opt_state = optimizer.update(grads, opt_state, params=params)
params = eqx.apply_updates(params, updates)
return params, opt_state, loss_val
FAQ
Start from the engine. PyTorch records operations on a tape as Python code runs, JAX transforms pure functions with grad and jit, and TensorFlow records gradients with GradientTape. Keras adds a high-level API over any of the three, and Transformers supplies pretrained models.
Both compute tensors on GPUs and differentiate them automatically. PyTorch records operations as Python code runs. TensorFlow records gradients inside a GradientTape block and also offers a stable C++ API. On Windows, TensorFlow's GPU builds run through WSL, the Windows Subsystem for Linux.
JAX transforms functions: jax.grad differentiates a function, jax.jit compiles it with XLA, and the two compose. Those transforms require pure functions, so model state passes in and out as arguments. PyTorch keeps state inside module objects and records gradients as the code runs.
Keras is a high-level API for building and training models, and TensorFlow is one of the engines it runs on. The current Keras also runs on JAX and PyTorch, and the previous version remains available as the tf-keras package.
Keras defines a model as layers and trains it through its own API, and it can use PyTorch as its backend. Plain PyTorch leaves the training loop to the program, which controls each step.
Flax is a neural network library for JAX. Its NNX API defines models as regular Python objects with mutable state, and JAX transforms then compile and differentiate them.
For coding agents
Found your deep learning library? Help your agent use it.
Connect Exa so your coding agent can find the library’s documentation, check its API, and look up implementations while you build.