Powered by AppSignal & Oban Pro
Would you like to see your link here? Contact us

Nx

books/ai/nx.livemd

Nx

Mix.install([
  {:nx, "~> 0.6.4"}
])

Tensor Creation

data = [[1, 2], [3, 4], [5, 6]]
tensor = data |> Nx.tensor()

Tensor Operations

tensor |> Nx.to_heatmap()
tensor |> Nx.shape()
tensor |> Nx.exp()
# softmax
Nx.divide(Nx.exp(tensor), Nx.sum(Nx.exp(tensor)))