@Operator(group="linalg") public final class LoadAndRemapMatrix extends PrimitiveOp implements Operand<Float>
at `ckpt_path` and potentially reorders its rows and columns using the specified remappings.
Most users should use one of the wrapper initializers (such as `tf.contrib.framework.load_and_remap_matrix_initializer`) instead of this function directly.
The remappings are 1-D tensors with the following properties:
The remapping tensors can be generated using the GenerateVocabRemapping op.
As an example, with row_remapping = [1, 0, -1], col_remapping = [0, 2, -1], initializing_values = [0.5, -0.5, 0.25, -0.25, 42], and w(i, j) representing the value from row i, column j of the old tensor in the checkpoint, the output matrix will look like the following:
[[w(1, 0), w(1, 2), 0.5], [w(0, 0), w(0, 2), -0.5], [0.25, -0.25, 42]]
Modifier and Type | Class and Description |
---|---|
static class |
LoadAndRemapMatrix.Options
Optional attributes for
LoadAndRemapMatrix |
operation
Modifier and Type | Method and Description |
---|---|
Output<Float> |
asOutput()
Returns the symbolic handle of a tensor.
|
static LoadAndRemapMatrix |
create(Scope scope,
Operand<String> ckptPath,
Operand<String> oldTensorName,
Operand<Long> rowRemapping,
Operand<Long> colRemapping,
Operand<Float> initializingValues,
Long numRows,
Long numCols,
LoadAndRemapMatrix.Options... options)
Factory method to create a class wrapping a new LoadAndRemapMatrix operation.
|
static LoadAndRemapMatrix.Options |
maxRowsInMemory(Long maxRowsInMemory) |
Output<Float> |
outputMatrix()
Output matrix containing existing values loaded from the
checkpoint, and with any missing values filled in from initializing_values.
|
equals, hashCode, op, toString
public static LoadAndRemapMatrix create(Scope scope, Operand<String> ckptPath, Operand<String> oldTensorName, Operand<Long> rowRemapping, Operand<Long> colRemapping, Operand<Float> initializingValues, Long numRows, Long numCols, LoadAndRemapMatrix.Options... options)
scope
- current scopeckptPath
- Path to the TensorFlow checkpoint (version 2, `TensorBundle`) from
which the old matrix `Tensor` will be loaded.oldTensorName
- Name of the 2-D `Tensor` to load from checkpoint.rowRemapping
- An int `Tensor` of row remappings (generally created by
`generate_vocab_remapping`). Even if no row remapping is needed, this must
still be an index-valued Tensor (e.g. [0, 1, 2, ...]), or a shifted
index-valued `Tensor` (e.g. [8, 9, 10, ...], for partitioned `Variables`).colRemapping
- An int `Tensor` of column remappings (generally created by
`generate_vocab_remapping`). May be a size-0 `Tensor` if only row remapping
is to be done (e.g. column ordering is the same).initializingValues
- A float `Tensor` containing values to fill in for cells
in the output matrix that are not loaded from the checkpoint. Length must be
exactly the same as the number of missing / new cells.numRows
- Number of rows (length of the 1st dimension) in the output matrix.numCols
- Number of columns (length of the 2nd dimension) in the output matrix.options
- carries optional attributes valuespublic static LoadAndRemapMatrix.Options maxRowsInMemory(Long maxRowsInMemory)
maxRowsInMemory
- The maximum number of rows to load from the checkpoint at
once. If less than or equal to 0, the entire matrix will be loaded into
memory. Setting this arg trades increased disk reads for lower memory usage.public Output<Float> outputMatrix()
public Output<Float> asOutput()
Operand
Inputs to TensorFlow operations are outputs of another TensorFlow operation. This method is used to obtain a symbolic handle that represents the computation of the input.
asOutput
in interface Operand<Float>
OperationBuilder.addInput(Output)
Copyright © 2022. All rights reserved.