MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / __init__

Method __init__

tensorflow/python/ops/lookup_ops.py:552–632  ·  view source on GitHub ↗

Constructs a table initializer object to populate from a text file. It generates one key-value pair per line. The type of table key and value are specified by `key_dtype` and `value_dtype`, respectively. Similarly the content of the key and value are specified by the key_index and v

(self,
               filename,
               key_dtype,
               key_index,
               value_dtype,
               value_index,
               vocab_size=None,
               delimiter="\t",
               name=None)

Source from the content-addressed store, hash-verified

550 """
551
552 def __init__(self,
553 filename,
554 key_dtype,
555 key_index,
556 value_dtype,
557 value_index,
558 vocab_size=None,
559 delimiter="\t",
560 name=None):
561 """Constructs a table initializer object to populate from a text file.
562
563 It generates one key-value pair per line. The type of table key and
564 value are specified by `key_dtype` and `value_dtype`, respectively.
565 Similarly the content of the key and value are specified by the key_index
566 and value_index.
567
568 - TextFileIndex.LINE_NUMBER means use the line number starting from zero,
569 expects data type int64.
570 - TextFileIndex.WHOLE_LINE means use the whole line content, expects data
571 type string.
572 - A value >=0 means use the index (starting at zero) of the split line based
573 on `delimiter`.
574
575 Args:
576 filename: The filename of the text file to be used for initialization. The
577 path must be accessible from wherever the graph is initialized (eg.
578 trainer or eval workers). The filename may be a scalar `Tensor`.
579 key_dtype: The `key` data type.
580 key_index: the index that represents information of a line to get the
581 table 'key' values from.
582 value_dtype: The `value` data type.
583 value_index: the index that represents information of a line to get the
584 table 'value' values from.'
585 vocab_size: The number of elements in the file, if known.
586 delimiter: The delimiter to separate fields in a line.
587 name: A name for the operation (optional).
588
589 Raises:
590 ValueError: when the filename is empty, or when the table key and value
591 data types do not match the expected data types.
592 """
593 if not isinstance(filename, ops.Tensor) and not filename:
594 raise ValueError("Filename required for %s." % name)
595
596 self._filename_arg = filename
597 key_dtype = dtypes.as_dtype(key_dtype)
598 value_dtype = dtypes.as_dtype(value_dtype)
599
600 if key_index < -2:
601 raise ValueError("Invalid key index %s." % (key_index))
602
603 if key_index == TextFileIndex.LINE_NUMBER and key_dtype != dtypes.int64:
604 raise ValueError("Signature mismatch. Keys must be dtype %s, got %s." %
605 (dtypes.int64, key_dtype))
606 if ((key_index == TextFileIndex.WHOLE_LINE) and
607 (not key_dtype.is_integer) and (key_dtype != dtypes.string)):
608 raise ValueError(
609 "Signature mismatch. Keys must be integer or string, got %s." %

Callers

nothing calls this directly

Calls 2

_track_trackableMethod · 0.45
__init__Method · 0.45

Tested by

no test coverage detected