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
- Host: GitHub
- URL: https://github.com/dirkschumacher/tfjs-diag
- Owner: dirkschumacher
- License: mit
- Created: 2019-06-23T06:01:59.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2023-05-06T03:10:16.000Z (about 3 years ago)
- Last Synced: 2025-10-26T03:44:32.677Z (8 months ago)
- Topics: tensorflow, tensorflow-js
- Language: JavaScript
- Homepage:
- Size: 15.6 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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]
// ]
```