Loads a 2-D (matrix) Tensor
with name old_tensor_name
from the checkpoint
tf.raw_ops.LoadAndRemapMatrix(
ckpt_path,
old_tensor_name,
row_remapping,
col_remapping,
initializing_values,
num_rows,
num_cols,
max_rows_in_memory=-1,
name=None
)
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:
row_remapping
must have exactlynum_rows
entries. Rowi
of the output matrix will be initialized from the row corresponding to indexrow_remapping[i]
in the oldTensor
from the checkpoint.col_remapping
must have either 0 entries (indicating that no column reordering is needed) ornum_cols
entries. If specified, columnj
of the output matrix will be initialized from the column corresponding to indexcol_remapping[j]
in the oldTensor
from the checkpoint.- A value of -1 in either of the remappings signifies a "missing" entry. In that
case, values from the
initializing_values
tensor will be used to fill that missing row or column. Ifrow_remapping
hasr
missing entries andcol_remapping
hasc
missing entries, then the following condition must be true:
(r * num_cols) + (c * num_rows) - (r * c) == len(initializing_values)
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]]
Returns | |
---|---|
A Tensor of type float32 .
|