liveBook · Manning

Embedding

As explained in Deep Learning with JAX

A rank-1 multidimensional array with one axis, used here for model outputs such as class probabilities.

A vector is a rank-1 tensor: a multidimensional array with one axis. Its size counts elements, while its rank counts dimensions. A classification model’s output for one input is a vector of class probabilities, with one element per class. section 2.5

Vectors also appear inside larger computations. A batch of predictions adds another dimension, producing a matrix rather than a vector; JAX’s vmap can apply a single-input prediction function across that batch. In parallel workloads, vector elements can be partitioned across devices, and dot products combine corresponding products from the shards. section 2.5 section 8.1.3

From one prediction to a batch

A single prediction is a vector of class scores. Applying the vmapped function to 32 inputs produces an array with shape (32, 10): one 10-element prediction vector for each input. section 2.5

Listing 2.9 Using the vmapped function
batched_preds = batched_predict(params, random_flattened_images) #1
print(batched_preds.shape)
>>> (32, 10)                                                     #2

Inspect the vmapped prediction call and its resulting batch shape. section 2.5

How Deep Learning with JAX covers it

How deep it goes
Explains rank, size, batching, vmap, dot products, and device sharding without developing vector internals.
Examples
Uses class-probability outputs, batched predictions, wide vectors, and two-dimensional mesh partitioning.
What it assumes
Assumes basic familiarity with NumPy-like multidimensional arrays while teaching tensor ranks from scalars through higher-dimensional arrays.
What you can do after
Apply it via JAX by distinguishing vector and batch shapes, using vmap, and interpreting sharded dot-product outputs.
How it connects
Connects vectors to tensors, scalars, matrices, batches, dot products, and sharding.

Also explained in

Compare how 47 books explain embedding →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Deep Learning with JAX. The section links point to the parts of the book it draws on.