# tensorflow ：： ops ：： MatrixSetDiagV2

`#include <array_ops.h>`

## 概要

`input``diagonal`与えられると、この操作は、最も内側の行列の指定された対角線を除いて、 `input`と同じ形状と値のテンソルを返します。これらは`diagonal`の値で上書きされます。

`input`次元は`r+1` `[I, J, ..., L, M, N]`です。 `k`がスカラーまたは`k[0] == k[1]`場合、 `diagonal`次元は`r`次元`[I, J, ..., L, max_diag_len]`です。それ以外の場合は、 `r+1`次元`[I, J, ..., L, num_diags, max_diag_len]`ます。 `num_diags`は対角線の数、 `num_diags = k[1] - k[0] + 1`です。 `max_diag_len`は、範囲`[k[0], k[1]]``max_diag_len = min(M + min(k[1], 0), N + min(-k[0], 0))`の最長の対角線です`[k[0], k[1]]`

```output[i, j, ..., l, m, n]
= diagonal[i, j, ..., l, n-max(k[1], 0)] ; if n - m == k[1]
input[i, j, ..., l, m, n]              ; otherwise
```

さもないと、

```output[i, j, ..., l, m, n]
= diagonal[i, j, ..., l, diag_index, index_in_diag] ; if k[0] <= d <= k[1]
input[i, j, ..., l, m, n]                         ; otherwise
```
ここで、 `d = n - m``diag_index = k[1] - d` 、および`index_in_diag = n - max(d, 0)`

```# The main diagonal.
input = np.array([[[7, 7, 7, 7],              # Input shape: (2, 3, 4)
[7, 7, 7, 7],
[7, 7, 7, 7]],
[[7, 7, 7, 7],
[7, 7, 7, 7],
[7, 7, 7, 7]]])
diagonal = np.array([[1, 2, 3],               # Diagonal shape: (2, 3)
[4, 5, 6]])
tf.matrix_set_diag(diagonal) ==> [[[1, 7, 7, 7],  # Output shape: (2, 3, 4)
[7, 2, 7, 7],
[7, 7, 3, 7]],
[[4, 7, 7, 7],
[7, 5, 7, 7],
[7, 7, 6, 7]]]```

```# A superdiagonal (per batch).
tf.matrix_set_diag(diagonal, k = 1)
==> [[[7, 1, 7, 7],  # Output shape: (2, 3, 4)
[7, 7, 2, 7],
[7, 7, 7, 3]],
[[7, 4, 7, 7],
[7, 7, 5, 7],
[7, 7, 7, 6]]]```

```# A band of diagonals.
diagonals = np.array([[[1, 2, 3],  # Diagonal shape: (2, 2, 3)
[4, 5, 0]],
[[6, 1, 2],
[3, 4, 0]]])
tf.matrix_set_diag(diagonals, k = (-1, 0))
==> [[[1, 7, 7, 7],  # Output shape: (2, 3, 4)
[4, 2, 7, 7],
[0, 5, 3, 7]],
[[6, 7, 7, 7],
[3, 1, 7, 7],
[7, 4, 2, 7]]]```

```
Arguments:
scope: A Scope object
input: Rank `r+1`, where `r >= 1`.
diagonal: Rank `r` when `k` is an integer or `k[0] == k[1]`. Otherwise, it has rank `r+1`. `k >= 1`.
k: Diagonal offset(s). Positive value means superdiagonal, 0 refers to the main diagonal, and negative value means subdiagonals. `k` can be a single integer (for a single diagonal) or a pair of integers specifying the low and high ends of a matrix band. `k[0]` must not be larger than `k[1]`.

Returns:
`Output`: Rank `r+1`, with `output.shape = input.shape`.

Constructors and Destructors

`MatrixSetDiagV2(const ::tensorflow::Scope & scope, ::tensorflow::Input input, ::tensorflow::Input diagonal, ::tensorflow::Input k)`

Public attributes

`operation`

`Operation`

`output`

`::tensorflow::Output`

Public functions

`node() const `

`::tensorflow::Node *`

`operator::tensorflow::Input() const `

```
``````
```

`operator::tensorflow::Output() const `

```
``````
```

Public attributes

operation
Operation operation 出力::tensorflow::Output output公の行事 MatrixSetDiagV2  MatrixSetDiagV2(
const ::tensorflow::Scope & scope,
::tensorflow::Input input,
::tensorflow::Input diagonal,
::tensorflow::Input k
) ノード::tensorflow::Node * node() const   operator :: tensorflow :: Input  operator::tensorflow::Input() const   operator :: tensorflow :: Output  operator::tensorflow::Output() const

```
[{ "type": "thumb-down", "id": "missingTheInformationINeed", "label":"必要な情報がない" },{ "type": "thumb-down", "id": "tooComplicatedTooManySteps", "label":"複雑すぎる / 手順が多すぎる" },{ "type": "thumb-down", "id": "outOfDate", "label":"最新ではない" },{ "type": "thumb-down", "id": "translationIssue", "label":"翻訳に関する問題" },{ "type": "thumb-down", "id": "samplesCodeIssue", "label":"Samples / code issue" },{ "type": "thumb-down", "id": "otherDown", "label":"その他" }]
[{ "type": "thumb-up", "id": "easyToUnderstand", "label":"わかりやすい" },{ "type": "thumb-up", "id": "solvedMyProblem", "label":"問題の解決に役立った" },{ "type": "thumb-up", "id": "otherUp", "label":"その他" }]