An open API service indexing awesome lists of open source software.

https://github.com/dirkschumacher/tfjs-diag

Create a diagonal matrix (rank 2 Tensor) from a rank 1 Tensor in tensorflow.js
https://github.com/dirkschumacher/tfjs-diag

tensorflow tensorflow-js

Last synced: 2 months ago
JSON representation

Create a diagonal matrix (rank 2 Tensor) from a rank 1 Tensor in tensorflow.js

Awesome Lists containing this project

README

          

# tfjs-diag
Create a diagonal matrix (rank 2 Tensor) from a rank 1 Tensor

```js
const diag = require("tfjs-diag")
const input = tfc.tensor1d([1, 2, 3])
const result = diag(input)
// [
// [1, 0, 0],
// [0, 2, 0],
// [0, 0, 3]
// ]
```