repo
stringlengths
7
54
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
20
28.4k
docstring
stringlengths
1
46.3k
docstring_tokens
listlengths
1
1.66k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
summary
stringlengths
4
350
obf_code
stringlengths
7.85k
764k
pytorch/text
torchtext/vocab.py
Vocab.set_vectors
def set_vectors(self, stoi, vectors, dim, unk_init=torch.Tensor.zero_): """ Set the vectors for the Vocab instance from a collection of Tensors. Arguments: stoi: A dictionary of string to the index of the associated vector in the `vectors` input argument. ...
python
def set_vectors(self, stoi, vectors, dim, unk_init=torch.Tensor.zero_): """ Set the vectors for the Vocab instance from a collection of Tensors. Arguments: stoi: A dictionary of string to the index of the associated vector in the `vectors` input argument. ...
[ "def", "set_vectors", "(", "self", ",", "stoi", ",", "vectors", ",", "dim", ",", "unk_init", "=", "torch", ".", "Tensor", ".", "zero_", ")", ":", "self", ".", "vectors", "=", "torch", ".", "Tensor", "(", "len", "(", "self", ")", ",", "dim", ")", ...
Set the vectors for the Vocab instance from a collection of Tensors. Arguments: stoi: A dictionary of string to the index of the associated vector in the `vectors` input argument. vectors: An indexed iterable (or other structure supporting __getitem__) that ...
[ "Set", "the", "vectors", "for", "the", "Vocab", "instance", "from", "a", "collection", "of", "Tensors", "." ]
26bfce6869dc704f1d86792f9a681d453d7e7bb8
https://github.com/pytorch/text/blob/26bfce6869dc704f1d86792f9a681d453d7e7bb8/torchtext/vocab.py#L167-L189
train
Set the vectors for the Vocab instance from a collection of Tensors.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pytorch/text
torchtext/datasets/sst.py
SST.splits
def splits(cls, text_field, label_field, root='.data', train='train.txt', validation='dev.txt', test='test.txt', train_subtrees=False, **kwargs): """Create dataset objects for splits of the SST dataset. Arguments: text_field: The field that will be used for the...
python
def splits(cls, text_field, label_field, root='.data', train='train.txt', validation='dev.txt', test='test.txt', train_subtrees=False, **kwargs): """Create dataset objects for splits of the SST dataset. Arguments: text_field: The field that will be used for the...
[ "def", "splits", "(", "cls", ",", "text_field", ",", "label_field", ",", "root", "=", "'.data'", ",", "train", "=", "'train.txt'", ",", "validation", "=", "'dev.txt'", ",", "test", "=", "'test.txt'", ",", "train_subtrees", "=", "False", ",", "*", "*", "k...
Create dataset objects for splits of the SST dataset. Arguments: text_field: The field that will be used for the sentence. label_field: The field that will be used for label data. root: The root directory that the dataset's zip archive will be expanded into; ...
[ "Create", "dataset", "objects", "for", "splits", "of", "the", "SST", "dataset", "." ]
26bfce6869dc704f1d86792f9a681d453d7e7bb8
https://github.com/pytorch/text/blob/26bfce6869dc704f1d86792f9a681d453d7e7bb8/torchtext/datasets/sst.py#L47-L78
train
Creates a tuple of Dataset objects for splits of the SST dataset.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pytorch/text
torchtext/datasets/sst.py
SST.iters
def iters(cls, batch_size=32, device=0, root='.data', vectors=None, **kwargs): """Create iterator objects for splits of the SST dataset. Arguments: batch_size: Batch_size device: Device to create batches on. Use - 1 for CPU and None for the currently active GPU d...
python
def iters(cls, batch_size=32, device=0, root='.data', vectors=None, **kwargs): """Create iterator objects for splits of the SST dataset. Arguments: batch_size: Batch_size device: Device to create batches on. Use - 1 for CPU and None for the currently active GPU d...
[ "def", "iters", "(", "cls", ",", "batch_size", "=", "32", ",", "device", "=", "0", ",", "root", "=", "'.data'", ",", "vectors", "=", "None", ",", "*", "*", "kwargs", ")", ":", "TEXT", "=", "data", ".", "Field", "(", ")", "LABEL", "=", "data", "...
Create iterator objects for splits of the SST dataset. Arguments: batch_size: Batch_size device: Device to create batches on. Use - 1 for CPU and None for the currently active GPU device. root: The root directory that the dataset's zip archive will be ...
[ "Create", "iterator", "objects", "for", "splits", "of", "the", "SST", "dataset", "." ]
26bfce6869dc704f1d86792f9a681d453d7e7bb8
https://github.com/pytorch/text/blob/26bfce6869dc704f1d86792f9a681d453d7e7bb8/torchtext/datasets/sst.py#L81-L104
train
Create iterator objects for splits of the SST dataset.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pytorch/text
torchtext/data/utils.py
interleave_keys
def interleave_keys(a, b): """Interleave bits from two sort keys to form a joint sort key. Examples that are similar in both of the provided keys will have similar values for the key defined by this function. Useful for tasks with two text fields like machine translation or natural language inference. ...
python
def interleave_keys(a, b): """Interleave bits from two sort keys to form a joint sort key. Examples that are similar in both of the provided keys will have similar values for the key defined by this function. Useful for tasks with two text fields like machine translation or natural language inference. ...
[ "def", "interleave_keys", "(", "a", ",", "b", ")", ":", "def", "interleave", "(", "args", ")", ":", "return", "''", ".", "join", "(", "[", "x", "for", "t", "in", "zip", "(", "*", "args", ")", "for", "x", "in", "t", "]", ")", "return", "int", ...
Interleave bits from two sort keys to form a joint sort key. Examples that are similar in both of the provided keys will have similar values for the key defined by this function. Useful for tasks with two text fields like machine translation or natural language inference.
[ "Interleave", "bits", "from", "two", "sort", "keys", "to", "form", "a", "joint", "sort", "key", "." ]
26bfce6869dc704f1d86792f9a681d453d7e7bb8
https://github.com/pytorch/text/blob/26bfce6869dc704f1d86792f9a681d453d7e7bb8/torchtext/data/utils.py#L89-L98
train
Interleave bits from two sort keys to form a joint sort key.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pytorch/text
torchtext/data/utils.py
RandomShuffler.use_internal_state
def use_internal_state(self): """Use a specific RNG state.""" old_state = random.getstate() random.setstate(self._random_state) yield self._random_state = random.getstate() random.setstate(old_state)
python
def use_internal_state(self): """Use a specific RNG state.""" old_state = random.getstate() random.setstate(self._random_state) yield self._random_state = random.getstate() random.setstate(old_state)
[ "def", "use_internal_state", "(", "self", ")", ":", "old_state", "=", "random", ".", "getstate", "(", ")", "random", ".", "setstate", "(", "self", ".", "_random_state", ")", "yield", "self", ".", "_random_state", "=", "random", ".", "getstate", "(", ")", ...
Use a specific RNG state.
[ "Use", "a", "specific", "RNG", "state", "." ]
26bfce6869dc704f1d86792f9a681d453d7e7bb8
https://github.com/pytorch/text/blob/26bfce6869dc704f1d86792f9a681d453d7e7bb8/torchtext/data/utils.py#L127-L133
train
Use a specific RNG state.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pytorch/text
torchtext/utils.py
download_from_url
def download_from_url(url, path): """Download file, with logic (from tensor2tensor) for Google Drive""" def process_response(r): chunk_size = 16 * 1024 total_size = int(r.headers.get('Content-length', 0)) with open(path, "wb") as file: with tqdm(total=total_size, unit='B', ...
python
def download_from_url(url, path): """Download file, with logic (from tensor2tensor) for Google Drive""" def process_response(r): chunk_size = 16 * 1024 total_size = int(r.headers.get('Content-length', 0)) with open(path, "wb") as file: with tqdm(total=total_size, unit='B', ...
[ "def", "download_from_url", "(", "url", ",", "path", ")", ":", "def", "process_response", "(", "r", ")", ":", "chunk_size", "=", "16", "*", "1024", "total_size", "=", "int", "(", "r", ".", "headers", ".", "get", "(", "'Content-length'", ",", "0", ")", ...
Download file, with logic (from tensor2tensor) for Google Drive
[ "Download", "file", "with", "logic", "(", "from", "tensor2tensor", ")", "for", "Google", "Drive" ]
26bfce6869dc704f1d86792f9a681d453d7e7bb8
https://github.com/pytorch/text/blob/26bfce6869dc704f1d86792f9a681d453d7e7bb8/torchtext/utils.py#L27-L57
train
Download file from url and save it to path
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pytorch/text
torchtext/utils.py
unicode_csv_reader
def unicode_csv_reader(unicode_csv_data, **kwargs): """Since the standard csv library does not handle unicode in Python 2, we need a wrapper. Borrowed and slightly modified from the Python docs: https://docs.python.org/2/library/csv.html#csv-examples""" if six.PY2: # csv.py doesn't do Unicode; e...
python
def unicode_csv_reader(unicode_csv_data, **kwargs): """Since the standard csv library does not handle unicode in Python 2, we need a wrapper. Borrowed and slightly modified from the Python docs: https://docs.python.org/2/library/csv.html#csv-examples""" if six.PY2: # csv.py doesn't do Unicode; e...
[ "def", "unicode_csv_reader", "(", "unicode_csv_data", ",", "*", "*", "kwargs", ")", ":", "if", "six", ".", "PY2", ":", "# csv.py doesn't do Unicode; encode temporarily as UTF-8:", "csv_reader", "=", "csv", ".", "reader", "(", "utf_8_encoder", "(", "unicode_csv_data", ...
Since the standard csv library does not handle unicode in Python 2, we need a wrapper. Borrowed and slightly modified from the Python docs: https://docs.python.org/2/library/csv.html#csv-examples
[ "Since", "the", "standard", "csv", "library", "does", "not", "handle", "unicode", "in", "Python", "2", "we", "need", "a", "wrapper", ".", "Borrowed", "and", "slightly", "modified", "from", "the", "Python", "docs", ":", "https", ":", "//", "docs", ".", "p...
26bfce6869dc704f1d86792f9a681d453d7e7bb8
https://github.com/pytorch/text/blob/26bfce6869dc704f1d86792f9a681d453d7e7bb8/torchtext/utils.py#L60-L72
train
A csv reader that returns a list of unicode data.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pytorch/text
torchtext/datasets/translation.py
TranslationDataset.splits
def splits(cls, exts, fields, path=None, root='.data', train='train', validation='val', test='test', **kwargs): """Create dataset objects for splits of a TranslationDataset. Arguments: exts: A tuple containing the extension to path for each language. fields: A tup...
python
def splits(cls, exts, fields, path=None, root='.data', train='train', validation='val', test='test', **kwargs): """Create dataset objects for splits of a TranslationDataset. Arguments: exts: A tuple containing the extension to path for each language. fields: A tup...
[ "def", "splits", "(", "cls", ",", "exts", ",", "fields", ",", "path", "=", "None", ",", "root", "=", "'.data'", ",", "train", "=", "'train'", ",", "validation", "=", "'val'", ",", "test", "=", "'test'", ",", "*", "*", "kwargs", ")", ":", "if", "p...
Create dataset objects for splits of a TranslationDataset. Arguments: exts: A tuple containing the extension to path for each language. fields: A tuple containing the fields that will be used for data in each language. path (str): Common prefix of the splits'...
[ "Create", "dataset", "objects", "for", "splits", "of", "a", "TranslationDataset", "." ]
26bfce6869dc704f1d86792f9a681d453d7e7bb8
https://github.com/pytorch/text/blob/26bfce6869dc704f1d86792f9a681d453d7e7bb8/torchtext/datasets/translation.py#L45-L72
train
Creates a tuple of Dataset objects for splits of a TranslationDataset.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pytorch/text
torchtext/datasets/translation.py
Multi30k.splits
def splits(cls, exts, fields, root='.data', train='train', validation='val', test='test2016', **kwargs): """Create dataset objects for splits of the Multi30k dataset. Arguments: exts: A tuple containing the extension to path for each language. fields: A tuple cont...
python
def splits(cls, exts, fields, root='.data', train='train', validation='val', test='test2016', **kwargs): """Create dataset objects for splits of the Multi30k dataset. Arguments: exts: A tuple containing the extension to path for each language. fields: A tuple cont...
[ "def", "splits", "(", "cls", ",", "exts", ",", "fields", ",", "root", "=", "'.data'", ",", "train", "=", "'train'", ",", "validation", "=", "'val'", ",", "test", "=", "'test2016'", ",", "*", "*", "kwargs", ")", ":", "# TODO: This is a _HORRIBLE_ patch rela...
Create dataset objects for splits of the Multi30k dataset. Arguments: exts: A tuple containing the extension to path for each language. fields: A tuple containing the fields that will be used for data in each language. root: Root dataset storage directory. De...
[ "Create", "dataset", "objects", "for", "splits", "of", "the", "Multi30k", "dataset", "." ]
26bfce6869dc704f1d86792f9a681d453d7e7bb8
https://github.com/pytorch/text/blob/26bfce6869dc704f1d86792f9a681d453d7e7bb8/torchtext/datasets/translation.py#L86-L114
train
Create dataset objects for splits of the Multi30k dataset.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pytorch/text
torchtext/datasets/translation.py
IWSLT.splits
def splits(cls, exts, fields, root='.data', train='train', validation='IWSLT16.TED.tst2013', test='IWSLT16.TED.tst2014', **kwargs): """Create dataset objects for splits of the IWSLT dataset. Arguments: exts: A tuple containing the extension to path for each lan...
python
def splits(cls, exts, fields, root='.data', train='train', validation='IWSLT16.TED.tst2013', test='IWSLT16.TED.tst2014', **kwargs): """Create dataset objects for splits of the IWSLT dataset. Arguments: exts: A tuple containing the extension to path for each lan...
[ "def", "splits", "(", "cls", ",", "exts", ",", "fields", ",", "root", "=", "'.data'", ",", "train", "=", "'train'", ",", "validation", "=", "'IWSLT16.TED.tst2013'", ",", "test", "=", "'IWSLT16.TED.tst2014'", ",", "*", "*", "kwargs", ")", ":", "cls", ".",...
Create dataset objects for splits of the IWSLT dataset. Arguments: exts: A tuple containing the extension to path for each language. fields: A tuple containing the fields that will be used for data in each language. root: Root dataset storage directory. Defau...
[ "Create", "dataset", "objects", "for", "splits", "of", "the", "IWSLT", "dataset", "." ]
26bfce6869dc704f1d86792f9a681d453d7e7bb8
https://github.com/pytorch/text/blob/26bfce6869dc704f1d86792f9a681d453d7e7bb8/torchtext/datasets/translation.py#L125-L161
train
Creates a tuple of dataset objects for splits of the IWSLT dataset.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pytorch/text
torchtext/data/field.py
RawField.process
def process(self, batch, *args, **kwargs): """ Process a list of examples to create a batch. Postprocess the batch with user-provided Pipeline. Args: batch (list(object)): A list of object from a batch of examples. Returns: object: Processed object given the inp...
python
def process(self, batch, *args, **kwargs): """ Process a list of examples to create a batch. Postprocess the batch with user-provided Pipeline. Args: batch (list(object)): A list of object from a batch of examples. Returns: object: Processed object given the inp...
[ "def", "process", "(", "self", ",", "batch", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "postprocessing", "is", "not", "None", ":", "batch", "=", "self", ".", "postprocessing", "(", "batch", ")", "return", "batch" ]
Process a list of examples to create a batch. Postprocess the batch with user-provided Pipeline. Args: batch (list(object)): A list of object from a batch of examples. Returns: object: Processed object given the input and custom postprocessing Pipeline.
[ "Process", "a", "list", "of", "examples", "to", "create", "a", "batch", "." ]
26bfce6869dc704f1d86792f9a681d453d7e7bb8
https://github.com/pytorch/text/blob/26bfce6869dc704f1d86792f9a681d453d7e7bb8/torchtext/data/field.py#L48-L61
train
Processes a list of examples to create a batch.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pytorch/text
torchtext/data/field.py
Field.preprocess
def preprocess(self, x): """Load a single example using this field, tokenizing if necessary. If the input is a Python 2 `str`, it will be converted to Unicode first. If `sequential=True`, it will be tokenized. Then the input will be optionally lowercased and passed to the user-provided ...
python
def preprocess(self, x): """Load a single example using this field, tokenizing if necessary. If the input is a Python 2 `str`, it will be converted to Unicode first. If `sequential=True`, it will be tokenized. Then the input will be optionally lowercased and passed to the user-provided ...
[ "def", "preprocess", "(", "self", ",", "x", ")", ":", "if", "(", "six", ".", "PY2", "and", "isinstance", "(", "x", ",", "six", ".", "string_types", ")", "and", "not", "isinstance", "(", "x", ",", "six", ".", "text_type", ")", ")", ":", "x", "=", ...
Load a single example using this field, tokenizing if necessary. If the input is a Python 2 `str`, it will be converted to Unicode first. If `sequential=True`, it will be tokenized. Then the input will be optionally lowercased and passed to the user-provided `preprocessing` Pipeline.
[ "Load", "a", "single", "example", "using", "this", "field", "tokenizing", "if", "necessary", "." ]
26bfce6869dc704f1d86792f9a681d453d7e7bb8
https://github.com/pytorch/text/blob/26bfce6869dc704f1d86792f9a681d453d7e7bb8/torchtext/data/field.py#L204-L223
train
Load a single example using this field tokenizing if necessary.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pytorch/text
torchtext/data/field.py
Field.process
def process(self, batch, device=None): """ Process a list of examples to create a torch.Tensor. Pad, numericalize, and postprocess a batch and create a tensor. Args: batch (list(object)): A list of object from a batch of examples. Returns: torch.autograd.Variabl...
python
def process(self, batch, device=None): """ Process a list of examples to create a torch.Tensor. Pad, numericalize, and postprocess a batch and create a tensor. Args: batch (list(object)): A list of object from a batch of examples. Returns: torch.autograd.Variabl...
[ "def", "process", "(", "self", ",", "batch", ",", "device", "=", "None", ")", ":", "padded", "=", "self", ".", "pad", "(", "batch", ")", "tensor", "=", "self", ".", "numericalize", "(", "padded", ",", "device", "=", "device", ")", "return", "tensor" ...
Process a list of examples to create a torch.Tensor. Pad, numericalize, and postprocess a batch and create a tensor. Args: batch (list(object)): A list of object from a batch of examples. Returns: torch.autograd.Variable: Processed object given the input and...
[ "Process", "a", "list", "of", "examples", "to", "create", "a", "torch", ".", "Tensor", "." ]
26bfce6869dc704f1d86792f9a681d453d7e7bb8
https://github.com/pytorch/text/blob/26bfce6869dc704f1d86792f9a681d453d7e7bb8/torchtext/data/field.py#L225-L238
train
Process a list of examples to create a torch. Tensor.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pytorch/text
torchtext/data/field.py
Field.pad
def pad(self, minibatch): """Pad a batch of examples using this field. Pads to self.fix_length if provided, otherwise pads to the length of the longest example in the batch. Prepends self.init_token and appends self.eos_token if those attributes are not None. Returns a tuple of the ...
python
def pad(self, minibatch): """Pad a batch of examples using this field. Pads to self.fix_length if provided, otherwise pads to the length of the longest example in the batch. Prepends self.init_token and appends self.eos_token if those attributes are not None. Returns a tuple of the ...
[ "def", "pad", "(", "self", ",", "minibatch", ")", ":", "minibatch", "=", "list", "(", "minibatch", ")", "if", "not", "self", ".", "sequential", ":", "return", "minibatch", "if", "self", ".", "fix_length", "is", "None", ":", "max_len", "=", "max", "(", ...
Pad a batch of examples using this field. Pads to self.fix_length if provided, otherwise pads to the length of the longest example in the batch. Prepends self.init_token and appends self.eos_token if those attributes are not None. Returns a tuple of the padded list and a list containing...
[ "Pad", "a", "batch", "of", "examples", "using", "this", "field", "." ]
26bfce6869dc704f1d86792f9a681d453d7e7bb8
https://github.com/pytorch/text/blob/26bfce6869dc704f1d86792f9a681d453d7e7bb8/torchtext/data/field.py#L240-L275
train
Pads a batch of examples using this field.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pytorch/text
torchtext/data/field.py
Field.build_vocab
def build_vocab(self, *args, **kwargs): """Construct the Vocab object for this field from one or more datasets. Arguments: Positional arguments: Dataset objects or other iterable data sources from which to construct the Vocab object that represents the set of...
python
def build_vocab(self, *args, **kwargs): """Construct the Vocab object for this field from one or more datasets. Arguments: Positional arguments: Dataset objects or other iterable data sources from which to construct the Vocab object that represents the set of...
[ "def", "build_vocab", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "counter", "=", "Counter", "(", ")", "sources", "=", "[", "]", "for", "arg", "in", "args", ":", "if", "isinstance", "(", "arg", ",", "Dataset", ")", ":", "sou...
Construct the Vocab object for this field from one or more datasets. Arguments: Positional arguments: Dataset objects or other iterable data sources from which to construct the Vocab object that represents the set of possible values for this field. If ...
[ "Construct", "the", "Vocab", "object", "for", "this", "field", "from", "one", "or", "more", "datasets", "." ]
26bfce6869dc704f1d86792f9a681d453d7e7bb8
https://github.com/pytorch/text/blob/26bfce6869dc704f1d86792f9a681d453d7e7bb8/torchtext/data/field.py#L277-L309
train
Construct the Vocab object for this field from one or more datasets.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pytorch/text
torchtext/data/field.py
Field.numericalize
def numericalize(self, arr, device=None): """Turn a batch of examples that use this field into a Variable. If the field has include_lengths=True, a tensor of lengths will be included in the return value. Arguments: arr (List[List[str]], or tuple of (List[List[str]], List[in...
python
def numericalize(self, arr, device=None): """Turn a batch of examples that use this field into a Variable. If the field has include_lengths=True, a tensor of lengths will be included in the return value. Arguments: arr (List[List[str]], or tuple of (List[List[str]], List[in...
[ "def", "numericalize", "(", "self", ",", "arr", ",", "device", "=", "None", ")", ":", "if", "self", ".", "include_lengths", "and", "not", "isinstance", "(", "arr", ",", "tuple", ")", ":", "raise", "ValueError", "(", "\"Field has include_lengths set to True, bu...
Turn a batch of examples that use this field into a Variable. If the field has include_lengths=True, a tensor of lengths will be included in the return value. Arguments: arr (List[List[str]], or tuple of (List[List[str]], List[int])): List of tokenized and padded ex...
[ "Turn", "a", "batch", "of", "examples", "that", "use", "this", "field", "into", "a", "Variable", "." ]
26bfce6869dc704f1d86792f9a681d453d7e7bb8
https://github.com/pytorch/text/blob/26bfce6869dc704f1d86792f9a681d453d7e7bb8/torchtext/data/field.py#L311-L368
train
Turn a batch of examples that use this field into a Variable.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pytorch/text
torchtext/data/field.py
SubwordField.segment
def segment(self, *args): """Segment one or more datasets with this subword field. Arguments: Positional arguments: Dataset objects or other indexable mutable sequences to segment. If a Dataset object is provided, all columns corresponding to this field are u...
python
def segment(self, *args): """Segment one or more datasets with this subword field. Arguments: Positional arguments: Dataset objects or other indexable mutable sequences to segment. If a Dataset object is provided, all columns corresponding to this field are u...
[ "def", "segment", "(", "self", ",", "*", "args", ")", ":", "sources", "=", "[", "]", "for", "arg", "in", "args", ":", "if", "isinstance", "(", "arg", ",", "Dataset", ")", ":", "sources", "+=", "[", "getattr", "(", "arg", ",", "name", ")", "for", ...
Segment one or more datasets with this subword field. Arguments: Positional arguments: Dataset objects or other indexable mutable sequences to segment. If a Dataset object is provided, all columns corresponding to this field are used; individual colum...
[ "Segment", "one", "or", "more", "datasets", "with", "this", "subword", "field", "." ]
26bfce6869dc704f1d86792f9a681d453d7e7bb8
https://github.com/pytorch/text/blob/26bfce6869dc704f1d86792f9a681d453d7e7bb8/torchtext/data/field.py#L424-L442
train
Segment one or more Dataset objects or other mutable sequences to the current subword field.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pytorch/text
torchtext/data/field.py
NestedField.preprocess
def preprocess(self, xs): """Preprocess a single example. Firstly, tokenization and the supplied preprocessing pipeline is applied. Since this field is always sequential, the result is a list. Then, each element of the list is preprocessed using ``self.nesting_field.preprocess`` and the...
python
def preprocess(self, xs): """Preprocess a single example. Firstly, tokenization and the supplied preprocessing pipeline is applied. Since this field is always sequential, the result is a list. Then, each element of the list is preprocessed using ``self.nesting_field.preprocess`` and the...
[ "def", "preprocess", "(", "self", ",", "xs", ")", ":", "return", "[", "self", ".", "nesting_field", ".", "preprocess", "(", "x", ")", "for", "x", "in", "super", "(", "NestedField", ",", "self", ")", ".", "preprocess", "(", "xs", ")", "]" ]
Preprocess a single example. Firstly, tokenization and the supplied preprocessing pipeline is applied. Since this field is always sequential, the result is a list. Then, each element of the list is preprocessed using ``self.nesting_field.preprocess`` and the resulting list is returned. ...
[ "Preprocess", "a", "single", "example", "." ]
26bfce6869dc704f1d86792f9a681d453d7e7bb8
https://github.com/pytorch/text/blob/26bfce6869dc704f1d86792f9a681d453d7e7bb8/torchtext/data/field.py#L528-L543
train
Preprocess a single example.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pytorch/text
torchtext/data/field.py
NestedField.pad
def pad(self, minibatch): """Pad a batch of examples using this field. If ``self.nesting_field.sequential`` is ``False``, each example in the batch must be a list of string tokens, and pads them as if by a ``Field`` with ``sequential=True``. Otherwise, each example must be a list of lis...
python
def pad(self, minibatch): """Pad a batch of examples using this field. If ``self.nesting_field.sequential`` is ``False``, each example in the batch must be a list of string tokens, and pads them as if by a ``Field`` with ``sequential=True``. Otherwise, each example must be a list of lis...
[ "def", "pad", "(", "self", ",", "minibatch", ")", ":", "minibatch", "=", "list", "(", "minibatch", ")", "if", "not", "self", ".", "nesting_field", ".", "sequential", ":", "return", "super", "(", "NestedField", ",", "self", ")", ".", "pad", "(", "miniba...
Pad a batch of examples using this field. If ``self.nesting_field.sequential`` is ``False``, each example in the batch must be a list of string tokens, and pads them as if by a ``Field`` with ``sequential=True``. Otherwise, each example must be a list of list of tokens. Using ``self.nes...
[ "Pad", "a", "batch", "of", "examples", "using", "this", "field", "." ]
26bfce6869dc704f1d86792f9a681d453d7e7bb8
https://github.com/pytorch/text/blob/26bfce6869dc704f1d86792f9a681d453d7e7bb8/torchtext/data/field.py#L545-L644
train
Pads a batch of examples using this field.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pytorch/text
torchtext/data/field.py
NestedField.build_vocab
def build_vocab(self, *args, **kwargs): """Construct the Vocab object for nesting field and combine it with this field's vocab. Arguments: Positional arguments: Dataset objects or other iterable data sources from which to construct the Vocab object that repre...
python
def build_vocab(self, *args, **kwargs): """Construct the Vocab object for nesting field and combine it with this field's vocab. Arguments: Positional arguments: Dataset objects or other iterable data sources from which to construct the Vocab object that repre...
[ "def", "build_vocab", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "sources", "=", "[", "]", "for", "arg", "in", "args", ":", "if", "isinstance", "(", "arg", ",", "Dataset", ")", ":", "sources", ".", "extend", "(", "[", "geta...
Construct the Vocab object for nesting field and combine it with this field's vocab. Arguments: Positional arguments: Dataset objects or other iterable data sources from which to construct the Vocab object that represents the set of possible values for the nesting fi...
[ "Construct", "the", "Vocab", "object", "for", "nesting", "field", "and", "combine", "it", "with", "this", "field", "s", "vocab", "." ]
26bfce6869dc704f1d86792f9a681d453d7e7bb8
https://github.com/pytorch/text/blob/26bfce6869dc704f1d86792f9a681d453d7e7bb8/torchtext/data/field.py#L646-L692
train
This method is used to build the Vocab object for this nesting field and combine it with self. vocab.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pytorch/text
torchtext/data/field.py
NestedField.numericalize
def numericalize(self, arrs, device=None): """Convert a padded minibatch into a variable tensor. Each item in the minibatch will be numericalized independently and the resulting tensors will be stacked at the first dimension. Arguments: arr (List[List[str]]): List of tokeni...
python
def numericalize(self, arrs, device=None): """Convert a padded minibatch into a variable tensor. Each item in the minibatch will be numericalized independently and the resulting tensors will be stacked at the first dimension. Arguments: arr (List[List[str]]): List of tokeni...
[ "def", "numericalize", "(", "self", ",", "arrs", ",", "device", "=", "None", ")", ":", "numericalized", "=", "[", "]", "self", ".", "nesting_field", ".", "include_lengths", "=", "False", "if", "self", ".", "include_lengths", ":", "arrs", ",", "sentence_len...
Convert a padded minibatch into a variable tensor. Each item in the minibatch will be numericalized independently and the resulting tensors will be stacked at the first dimension. Arguments: arr (List[List[str]]): List of tokenized and padded examples. device (str or to...
[ "Convert", "a", "padded", "minibatch", "into", "a", "variable", "tensor", "." ]
26bfce6869dc704f1d86792f9a681d453d7e7bb8
https://github.com/pytorch/text/blob/26bfce6869dc704f1d86792f9a681d453d7e7bb8/torchtext/data/field.py#L694-L723
train
Convert a padded minibatch into a variable tensor.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pytorch/text
torchtext/data/iterator.py
batch
def batch(data, batch_size, batch_size_fn=None): """Yield elements from data in chunks of batch_size.""" if batch_size_fn is None: def batch_size_fn(new, count, sofar): return count minibatch, size_so_far = [], 0 for ex in data: minibatch.append(ex) size_so_far = batc...
python
def batch(data, batch_size, batch_size_fn=None): """Yield elements from data in chunks of batch_size.""" if batch_size_fn is None: def batch_size_fn(new, count, sofar): return count minibatch, size_so_far = [], 0 for ex in data: minibatch.append(ex) size_so_far = batc...
[ "def", "batch", "(", "data", ",", "batch_size", ",", "batch_size_fn", "=", "None", ")", ":", "if", "batch_size_fn", "is", "None", ":", "def", "batch_size_fn", "(", "new", ",", "count", ",", "sofar", ")", ":", "return", "count", "minibatch", ",", "size_so...
Yield elements from data in chunks of batch_size.
[ "Yield", "elements", "from", "data", "in", "chunks", "of", "batch_size", "." ]
26bfce6869dc704f1d86792f9a681d453d7e7bb8
https://github.com/pytorch/text/blob/26bfce6869dc704f1d86792f9a681d453d7e7bb8/torchtext/data/iterator.py#L255-L271
train
Yields elements from data in chunks of batch_size.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pytorch/text
torchtext/data/iterator.py
pool
def pool(data, batch_size, key, batch_size_fn=lambda new, count, sofar: count, random_shuffler=None, shuffle=False, sort_within_batch=False): """Sort within buckets, then batch, then shuffle batches. Partitions data into chunks of size 100*batch_size, sorts examples within each chunk using sort_ke...
python
def pool(data, batch_size, key, batch_size_fn=lambda new, count, sofar: count, random_shuffler=None, shuffle=False, sort_within_batch=False): """Sort within buckets, then batch, then shuffle batches. Partitions data into chunks of size 100*batch_size, sorts examples within each chunk using sort_ke...
[ "def", "pool", "(", "data", ",", "batch_size", ",", "key", ",", "batch_size_fn", "=", "lambda", "new", ",", "count", ",", "sofar", ":", "count", ",", "random_shuffler", "=", "None", ",", "shuffle", "=", "False", ",", "sort_within_batch", "=", "False", ")...
Sort within buckets, then batch, then shuffle batches. Partitions data into chunks of size 100*batch_size, sorts examples within each chunk using sort_key, then batch these examples and shuffle the batches.
[ "Sort", "within", "buckets", "then", "batch", "then", "shuffle", "batches", "." ]
26bfce6869dc704f1d86792f9a681d453d7e7bb8
https://github.com/pytorch/text/blob/26bfce6869dc704f1d86792f9a681d453d7e7bb8/torchtext/data/iterator.py#L274-L293
train
Yields the examples within a random set of buckets.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pytorch/text
torchtext/data/iterator.py
Iterator.splits
def splits(cls, datasets, batch_sizes=None, **kwargs): """Create Iterator objects for multiple splits of a dataset. Arguments: datasets: Tuple of Dataset objects corresponding to the splits. The first such object should be the train set. batch_sizes: Tuple of bat...
python
def splits(cls, datasets, batch_sizes=None, **kwargs): """Create Iterator objects for multiple splits of a dataset. Arguments: datasets: Tuple of Dataset objects corresponding to the splits. The first such object should be the train set. batch_sizes: Tuple of bat...
[ "def", "splits", "(", "cls", ",", "datasets", ",", "batch_sizes", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "batch_sizes", "is", "None", ":", "batch_sizes", "=", "[", "kwargs", ".", "pop", "(", "'batch_size'", ")", "]", "*", "len", "(", ...
Create Iterator objects for multiple splits of a dataset. Arguments: datasets: Tuple of Dataset objects corresponding to the splits. The first such object should be the train set. batch_sizes: Tuple of batch sizes to use for the different splits, or None ...
[ "Create", "Iterator", "objects", "for", "multiple", "splits", "of", "a", "dataset", "." ]
26bfce6869dc704f1d86792f9a681d453d7e7bb8
https://github.com/pytorch/text/blob/26bfce6869dc704f1d86792f9a681d453d7e7bb8/torchtext/data/iterator.py#L79-L97
train
Create an iterator object for multiple splits of a dataset.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pytorch/text
torchtext/data/iterator.py
Iterator.data
def data(self): """Return the examples in the dataset in order, sorted, or shuffled.""" if self.sort: xs = sorted(self.dataset, key=self.sort_key) elif self.shuffle: xs = [self.dataset[i] for i in self.random_shuffler(range(len(self.dataset)))] else: x...
python
def data(self): """Return the examples in the dataset in order, sorted, or shuffled.""" if self.sort: xs = sorted(self.dataset, key=self.sort_key) elif self.shuffle: xs = [self.dataset[i] for i in self.random_shuffler(range(len(self.dataset)))] else: x...
[ "def", "data", "(", "self", ")", ":", "if", "self", ".", "sort", ":", "xs", "=", "sorted", "(", "self", ".", "dataset", ",", "key", "=", "self", ".", "sort_key", ")", "elif", "self", ".", "shuffle", ":", "xs", "=", "[", "self", ".", "dataset", ...
Return the examples in the dataset in order, sorted, or shuffled.
[ "Return", "the", "examples", "in", "the", "dataset", "in", "order", "sorted", "or", "shuffled", "." ]
26bfce6869dc704f1d86792f9a681d453d7e7bb8
https://github.com/pytorch/text/blob/26bfce6869dc704f1d86792f9a681d453d7e7bb8/torchtext/data/iterator.py#L99-L107
train
Return the examples in the dataset in order sorted or shuffled.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pytorch/text
torchtext/data/iterator.py
Iterator.init_epoch
def init_epoch(self): """Set up the batch generator for a new epoch.""" if self._restored_from_state: self.random_shuffler.random_state = self._random_state_this_epoch else: self._random_state_this_epoch = self.random_shuffler.random_state self.create_batches() ...
python
def init_epoch(self): """Set up the batch generator for a new epoch.""" if self._restored_from_state: self.random_shuffler.random_state = self._random_state_this_epoch else: self._random_state_this_epoch = self.random_shuffler.random_state self.create_batches() ...
[ "def", "init_epoch", "(", "self", ")", ":", "if", "self", ".", "_restored_from_state", ":", "self", ".", "random_shuffler", ".", "random_state", "=", "self", ".", "_random_state_this_epoch", "else", ":", "self", ".", "_random_state_this_epoch", "=", "self", ".",...
Set up the batch generator for a new epoch.
[ "Set", "up", "the", "batch", "generator", "for", "a", "new", "epoch", "." ]
26bfce6869dc704f1d86792f9a681d453d7e7bb8
https://github.com/pytorch/text/blob/26bfce6869dc704f1d86792f9a681d453d7e7bb8/torchtext/data/iterator.py#L109-L125
train
Initialize the batch generator for a new epoch.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pytorch/text
torchtext/data/batch.py
Batch.fromvars
def fromvars(cls, dataset, batch_size, train=None, **kwargs): """Create a Batch directly from a number of Variables.""" batch = cls() batch.batch_size = batch_size batch.dataset = dataset batch.fields = dataset.fields.keys() for k, v in kwargs.items(): setattr...
python
def fromvars(cls, dataset, batch_size, train=None, **kwargs): """Create a Batch directly from a number of Variables.""" batch = cls() batch.batch_size = batch_size batch.dataset = dataset batch.fields = dataset.fields.keys() for k, v in kwargs.items(): setattr...
[ "def", "fromvars", "(", "cls", ",", "dataset", ",", "batch_size", ",", "train", "=", "None", ",", "*", "*", "kwargs", ")", ":", "batch", "=", "cls", "(", ")", "batch", ".", "batch_size", "=", "batch_size", "batch", ".", "dataset", "=", "dataset", "ba...
Create a Batch directly from a number of Variables.
[ "Create", "a", "Batch", "directly", "from", "a", "number", "of", "Variables", "." ]
26bfce6869dc704f1d86792f9a681d453d7e7bb8
https://github.com/pytorch/text/blob/26bfce6869dc704f1d86792f9a681d453d7e7bb8/torchtext/data/batch.py#L37-L45
train
Create a Batch directly from a number of Variables.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pytorch/text
torchtext/datasets/sequence_tagging.py
UDPOS.splits
def splits(cls, fields, root=".data", train="en-ud-tag.v2.train.txt", validation="en-ud-tag.v2.dev.txt", test="en-ud-tag.v2.test.txt", **kwargs): """Downloads and loads the Universal Dependencies Version 2 POS Tagged data. """ return super(UDPOS, cls).split...
python
def splits(cls, fields, root=".data", train="en-ud-tag.v2.train.txt", validation="en-ud-tag.v2.dev.txt", test="en-ud-tag.v2.test.txt", **kwargs): """Downloads and loads the Universal Dependencies Version 2 POS Tagged data. """ return super(UDPOS, cls).split...
[ "def", "splits", "(", "cls", ",", "fields", ",", "root", "=", "\".data\"", ",", "train", "=", "\"en-ud-tag.v2.train.txt\"", ",", "validation", "=", "\"en-ud-tag.v2.dev.txt\"", ",", "test", "=", "\"en-ud-tag.v2.test.txt\"", ",", "*", "*", "kwargs", ")", ":", "r...
Downloads and loads the Universal Dependencies Version 2 POS Tagged data.
[ "Downloads", "and", "loads", "the", "Universal", "Dependencies", "Version", "2", "POS", "Tagged", "data", "." ]
26bfce6869dc704f1d86792f9a681d453d7e7bb8
https://github.com/pytorch/text/blob/26bfce6869dc704f1d86792f9a681d453d7e7bb8/torchtext/datasets/sequence_tagging.py#L57-L66
train
Downloads and loads the Universal Dependencies Version 2 POS Tagged data.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pytorch/text
torchtext/datasets/sequence_tagging.py
CoNLL2000Chunking.splits
def splits(cls, fields, root=".data", train="train.txt", test="test.txt", validation_frac=0.1, **kwargs): """Downloads and loads the CoNLL 2000 Chunking dataset. NOTE: There is only a train and test dataset so we use 10% of the train set as validation """ tr...
python
def splits(cls, fields, root=".data", train="train.txt", test="test.txt", validation_frac=0.1, **kwargs): """Downloads and loads the CoNLL 2000 Chunking dataset. NOTE: There is only a train and test dataset so we use 10% of the train set as validation """ tr...
[ "def", "splits", "(", "cls", ",", "fields", ",", "root", "=", "\".data\"", ",", "train", "=", "\"train.txt\"", ",", "test", "=", "\"test.txt\"", ",", "validation_frac", "=", "0.1", ",", "*", "*", "kwargs", ")", ":", "train", ",", "test", "=", "super", ...
Downloads and loads the CoNLL 2000 Chunking dataset. NOTE: There is only a train and test dataset so we use 10% of the train set as validation
[ "Downloads", "and", "loads", "the", "CoNLL", "2000", "Chunking", "dataset", ".", "NOTE", ":", "There", "is", "only", "a", "train", "and", "test", "dataset", "so", "we", "use", "10%", "of", "the", "train", "set", "as", "validation" ]
26bfce6869dc704f1d86792f9a681d453d7e7bb8
https://github.com/pytorch/text/blob/26bfce6869dc704f1d86792f9a681d453d7e7bb8/torchtext/datasets/sequence_tagging.py#L78-L103
train
Downloads and loads the CoNLL 2000 Chunking dataset.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pytorch/text
torchtext/datasets/imdb.py
IMDB.splits
def splits(cls, text_field, label_field, root='.data', train='train', test='test', **kwargs): """Create dataset objects for splits of the IMDB dataset. Arguments: text_field: The field that will be used for the sentence. label_field: The field that will be used fo...
python
def splits(cls, text_field, label_field, root='.data', train='train', test='test', **kwargs): """Create dataset objects for splits of the IMDB dataset. Arguments: text_field: The field that will be used for the sentence. label_field: The field that will be used fo...
[ "def", "splits", "(", "cls", ",", "text_field", ",", "label_field", ",", "root", "=", "'.data'", ",", "train", "=", "'train'", ",", "test", "=", "'test'", ",", "*", "*", "kwargs", ")", ":", "return", "super", "(", "IMDB", ",", "cls", ")", ".", "spl...
Create dataset objects for splits of the IMDB dataset. Arguments: text_field: The field that will be used for the sentence. label_field: The field that will be used for label data. root: Root dataset storage directory. Default is '.data'. train: The directory tha...
[ "Create", "dataset", "objects", "for", "splits", "of", "the", "IMDB", "dataset", "." ]
26bfce6869dc704f1d86792f9a681d453d7e7bb8
https://github.com/pytorch/text/blob/26bfce6869dc704f1d86792f9a681d453d7e7bb8/torchtext/datasets/imdb.py#L40-L55
train
Create dataset objects for splits of the IMDB dataset.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pytorch/text
torchtext/datasets/language_modeling.py
WikiText2.splits
def splits(cls, text_field, root='.data', train='wiki.train.tokens', validation='wiki.valid.tokens', test='wiki.test.tokens', **kwargs): """Create dataset objects for splits of the WikiText-2 dataset. This is the most flexible way to use the dataset. Arguments: ...
python
def splits(cls, text_field, root='.data', train='wiki.train.tokens', validation='wiki.valid.tokens', test='wiki.test.tokens', **kwargs): """Create dataset objects for splits of the WikiText-2 dataset. This is the most flexible way to use the dataset. Arguments: ...
[ "def", "splits", "(", "cls", ",", "text_field", ",", "root", "=", "'.data'", ",", "train", "=", "'wiki.train.tokens'", ",", "validation", "=", "'wiki.valid.tokens'", ",", "test", "=", "'wiki.test.tokens'", ",", "*", "*", "kwargs", ")", ":", "return", "super"...
Create dataset objects for splits of the WikiText-2 dataset. This is the most flexible way to use the dataset. Arguments: text_field: The field that will be used for text data. root: The root directory that the dataset's zip archive will be expanded into; theref...
[ "Create", "dataset", "objects", "for", "splits", "of", "the", "WikiText", "-", "2", "dataset", "." ]
26bfce6869dc704f1d86792f9a681d453d7e7bb8
https://github.com/pytorch/text/blob/26bfce6869dc704f1d86792f9a681d453d7e7bb8/torchtext/datasets/language_modeling.py#L40-L60
train
Create dataset objects for splits of the WikiText - 2 dataset.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pytorch/text
torchtext/datasets/language_modeling.py
WikiText2.iters
def iters(cls, batch_size=32, bptt_len=35, device=0, root='.data', vectors=None, **kwargs): """Create iterator objects for splits of the WikiText-2 dataset. This is the simplest way to use the dataset, and assumes common defaults for field, vocabulary, and iterator parameters. ...
python
def iters(cls, batch_size=32, bptt_len=35, device=0, root='.data', vectors=None, **kwargs): """Create iterator objects for splits of the WikiText-2 dataset. This is the simplest way to use the dataset, and assumes common defaults for field, vocabulary, and iterator parameters. ...
[ "def", "iters", "(", "cls", ",", "batch_size", "=", "32", ",", "bptt_len", "=", "35", ",", "device", "=", "0", ",", "root", "=", "'.data'", ",", "vectors", "=", "None", ",", "*", "*", "kwargs", ")", ":", "TEXT", "=", "data", ".", "Field", "(", ...
Create iterator objects for splits of the WikiText-2 dataset. This is the simplest way to use the dataset, and assumes common defaults for field, vocabulary, and iterator parameters. Arguments: batch_size: Batch size. bptt_len: Length of sequences for backpropagation th...
[ "Create", "iterator", "objects", "for", "splits", "of", "the", "WikiText", "-", "2", "dataset", "." ]
26bfce6869dc704f1d86792f9a681d453d7e7bb8
https://github.com/pytorch/text/blob/26bfce6869dc704f1d86792f9a681d453d7e7bb8/torchtext/datasets/language_modeling.py#L63-L91
train
Create an iterator object for splits of the WikiText - 2 dataset.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pytorch/text
torchtext/data/pipeline.py
Pipeline.call
def call(self, x, *args): """Apply _only_ the convert_token function of the current pipeline to the input. If the input is a list, a list with the results of applying the `convert_token` function to all input elements is returned. Arguments: x: The input to apply the...
python
def call(self, x, *args): """Apply _only_ the convert_token function of the current pipeline to the input. If the input is a list, a list with the results of applying the `convert_token` function to all input elements is returned. Arguments: x: The input to apply the...
[ "def", "call", "(", "self", ",", "x", ",", "*", "args", ")", ":", "if", "isinstance", "(", "x", ",", "list", ")", ":", "return", "[", "self", ".", "convert_token", "(", "tok", ",", "*", "args", ")", "for", "tok", "in", "x", "]", "return", "self...
Apply _only_ the convert_token function of the current pipeline to the input. If the input is a list, a list with the results of applying the `convert_token` function to all input elements is returned. Arguments: x: The input to apply the convert_token function to. ...
[ "Apply", "_only_", "the", "convert_token", "function", "of", "the", "current", "pipeline", "to", "the", "input", ".", "If", "the", "input", "is", "a", "list", "a", "list", "with", "the", "results", "of", "applying", "the", "convert_token", "function", "to", ...
26bfce6869dc704f1d86792f9a681d453d7e7bb8
https://github.com/pytorch/text/blob/26bfce6869dc704f1d86792f9a681d453d7e7bb8/torchtext/data/pipeline.py#L40-L53
train
Applies the convert_token function of the current pipeline alid to the input.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pytorch/text
torchtext/data/pipeline.py
Pipeline.add_before
def add_before(self, pipeline): """Add a Pipeline to be applied before this processing pipeline. Arguments: pipeline: The Pipeline or callable to apply before this Pipeline. """ if not isinstance(pipeline, Pipeline): pipeline = Pipeline(pipeline) ...
python
def add_before(self, pipeline): """Add a Pipeline to be applied before this processing pipeline. Arguments: pipeline: The Pipeline or callable to apply before this Pipeline. """ if not isinstance(pipeline, Pipeline): pipeline = Pipeline(pipeline) ...
[ "def", "add_before", "(", "self", ",", "pipeline", ")", ":", "if", "not", "isinstance", "(", "pipeline", ",", "Pipeline", ")", ":", "pipeline", "=", "Pipeline", "(", "pipeline", ")", "self", ".", "pipes", "=", "pipeline", ".", "pipes", "[", ":", "]", ...
Add a Pipeline to be applied before this processing pipeline. Arguments: pipeline: The Pipeline or callable to apply before this Pipeline.
[ "Add", "a", "Pipeline", "to", "be", "applied", "before", "this", "processing", "pipeline", "." ]
26bfce6869dc704f1d86792f9a681d453d7e7bb8
https://github.com/pytorch/text/blob/26bfce6869dc704f1d86792f9a681d453d7e7bb8/torchtext/data/pipeline.py#L55-L65
train
Add a Pipeline to be applied before this processing pipeline.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pytorch/text
torchtext/data/pipeline.py
Pipeline.add_after
def add_after(self, pipeline): """Add a Pipeline to be applied after this processing pipeline. Arguments: pipeline: The Pipeline or callable to apply after this Pipeline. """ if not isinstance(pipeline, Pipeline): pipeline = Pipeline(pipeline) ...
python
def add_after(self, pipeline): """Add a Pipeline to be applied after this processing pipeline. Arguments: pipeline: The Pipeline or callable to apply after this Pipeline. """ if not isinstance(pipeline, Pipeline): pipeline = Pipeline(pipeline) ...
[ "def", "add_after", "(", "self", ",", "pipeline", ")", ":", "if", "not", "isinstance", "(", "pipeline", ",", "Pipeline", ")", ":", "pipeline", "=", "Pipeline", "(", "pipeline", ")", "self", ".", "pipes", "=", "self", ".", "pipes", "[", ":", "]", "+",...
Add a Pipeline to be applied after this processing pipeline. Arguments: pipeline: The Pipeline or callable to apply after this Pipeline.
[ "Add", "a", "Pipeline", "to", "be", "applied", "after", "this", "processing", "pipeline", "." ]
26bfce6869dc704f1d86792f9a681d453d7e7bb8
https://github.com/pytorch/text/blob/26bfce6869dc704f1d86792f9a681d453d7e7bb8/torchtext/data/pipeline.py#L67-L77
train
Add a Pipeline to be applied after this processing pipeline.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pytorch/text
torchtext/data/dataset.py
check_split_ratio
def check_split_ratio(split_ratio): """Check that the split ratio argument is not malformed""" valid_ratio = 0. if isinstance(split_ratio, float): # Only the train set relative ratio is provided # Assert in bounds, validation size is zero assert 0. < split_ratio < 1., ( "...
python
def check_split_ratio(split_ratio): """Check that the split ratio argument is not malformed""" valid_ratio = 0. if isinstance(split_ratio, float): # Only the train set relative ratio is provided # Assert in bounds, validation size is zero assert 0. < split_ratio < 1., ( "...
[ "def", "check_split_ratio", "(", "split_ratio", ")", ":", "valid_ratio", "=", "0.", "if", "isinstance", "(", "split_ratio", ",", "float", ")", ":", "# Only the train set relative ratio is provided", "# Assert in bounds, validation size is zero", "assert", "0.", "<", "spli...
Check that the split ratio argument is not malformed
[ "Check", "that", "the", "split", "ratio", "argument", "is", "not", "malformed" ]
26bfce6869dc704f1d86792f9a681d453d7e7bb8
https://github.com/pytorch/text/blob/26bfce6869dc704f1d86792f9a681d453d7e7bb8/torchtext/data/dataset.py#L284-L311
train
Check that the split ratio argument is not malformed
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pytorch/text
torchtext/data/dataset.py
Dataset.split
def split(self, split_ratio=0.7, stratified=False, strata_field='label', random_state=None): """Create train-test(-valid?) splits from the instance's examples. Arguments: split_ratio (float or List of floats): a number [0, 1] denoting the amount of data to be u...
python
def split(self, split_ratio=0.7, stratified=False, strata_field='label', random_state=None): """Create train-test(-valid?) splits from the instance's examples. Arguments: split_ratio (float or List of floats): a number [0, 1] denoting the amount of data to be u...
[ "def", "split", "(", "self", ",", "split_ratio", "=", "0.7", ",", "stratified", "=", "False", ",", "strata_field", "=", "'label'", ",", "random_state", "=", "None", ")", ":", "train_ratio", ",", "test_ratio", ",", "val_ratio", "=", "check_split_ratio", "(", ...
Create train-test(-valid?) splits from the instance's examples. Arguments: split_ratio (float or List of floats): a number [0, 1] denoting the amount of data to be used for the training split (rest is used for validation), or a list of numbers denoting the relative s...
[ "Create", "train", "-", "test", "(", "-", "valid?", ")", "splits", "from", "the", "instance", "s", "examples", "." ]
26bfce6869dc704f1d86792f9a681d453d7e7bb8
https://github.com/pytorch/text/blob/26bfce6869dc704f1d86792f9a681d453d7e7bb8/torchtext/data/dataset.py#L86-L136
train
Create train - test - valid splits from the instance s examples.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pytorch/text
torchtext/data/dataset.py
Dataset.download
def download(cls, root, check=None): """Download and unzip an online archive (.zip, .gz, or .tgz). Arguments: root (str): Folder to download data to. check (str or None): Folder whose existence indicates that the dataset has already been downloaded, or ...
python
def download(cls, root, check=None): """Download and unzip an online archive (.zip, .gz, or .tgz). Arguments: root (str): Folder to download data to. check (str or None): Folder whose existence indicates that the dataset has already been downloaded, or ...
[ "def", "download", "(", "cls", ",", "root", ",", "check", "=", "None", ")", ":", "path", "=", "os", ".", "path", ".", "join", "(", "root", ",", "cls", ".", "name", ")", "check", "=", "path", "if", "check", "is", "None", "else", "check", "if", "...
Download and unzip an online archive (.zip, .gz, or .tgz). Arguments: root (str): Folder to download data to. check (str or None): Folder whose existence indicates that the dataset has already been downloaded, or None to check the existence of root/{cls.n...
[ "Download", "and", "unzip", "an", "online", "archive", "(", ".", "zip", ".", "gz", "or", ".", "tgz", ")", "." ]
26bfce6869dc704f1d86792f9a681d453d7e7bb8
https://github.com/pytorch/text/blob/26bfce6869dc704f1d86792f9a681d453d7e7bb8/torchtext/data/dataset.py#L157-L199
train
Download and unzip an online archive.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pytorch/text
torchtext/data/dataset.py
Dataset.filter_examples
def filter_examples(self, field_names): """Remove unknown words from dataset examples with respect to given field. Arguments: field_names (list(str)): Within example only the parts with field names in field_names will have their unknown words deleted. """ for...
python
def filter_examples(self, field_names): """Remove unknown words from dataset examples with respect to given field. Arguments: field_names (list(str)): Within example only the parts with field names in field_names will have their unknown words deleted. """ for...
[ "def", "filter_examples", "(", "self", ",", "field_names", ")", ":", "for", "i", ",", "example", "in", "enumerate", "(", "self", ".", "examples", ")", ":", "for", "field_name", "in", "field_names", ":", "vocab", "=", "set", "(", "self", ".", "fields", ...
Remove unknown words from dataset examples with respect to given field. Arguments: field_names (list(str)): Within example only the parts with field names in field_names will have their unknown words deleted.
[ "Remove", "unknown", "words", "from", "dataset", "examples", "with", "respect", "to", "given", "field", "." ]
26bfce6869dc704f1d86792f9a681d453d7e7bb8
https://github.com/pytorch/text/blob/26bfce6869dc704f1d86792f9a681d453d7e7bb8/torchtext/data/dataset.py#L201-L214
train
Remove unknown words from dataset examples with respect to given field.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pytorch/text
torchtext/datasets/nli.py
NLIDataset.splits
def splits(cls, text_field, label_field, parse_field=None, extra_fields={}, root='.data', train='train.jsonl', validation='val.jsonl', test='test.jsonl'): """Create dataset objects for splits of the SNLI dataset. This is the most flexible way to use the dataset. A...
python
def splits(cls, text_field, label_field, parse_field=None, extra_fields={}, root='.data', train='train.jsonl', validation='val.jsonl', test='test.jsonl'): """Create dataset objects for splits of the SNLI dataset. This is the most flexible way to use the dataset. A...
[ "def", "splits", "(", "cls", ",", "text_field", ",", "label_field", ",", "parse_field", "=", "None", ",", "extra_fields", "=", "{", "}", ",", "root", "=", "'.data'", ",", "train", "=", "'train.jsonl'", ",", "validation", "=", "'val.jsonl'", ",", "test", ...
Create dataset objects for splits of the SNLI dataset. This is the most flexible way to use the dataset. Arguments: text_field: The field that will be used for premise and hypothesis data. label_field: The field that will be used for label data. pars...
[ "Create", "dataset", "objects", "for", "splits", "of", "the", "SNLI", "dataset", "." ]
26bfce6869dc704f1d86792f9a681d453d7e7bb8
https://github.com/pytorch/text/blob/26bfce6869dc704f1d86792f9a681d453d7e7bb8/torchtext/datasets/nli.py#L46-L88
train
Create a new dataset object for splits of the SNLI dataset.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pytorch/text
torchtext/datasets/nli.py
NLIDataset.iters
def iters(cls, batch_size=32, device=0, root='.data', vectors=None, trees=False, **kwargs): """Create iterator objects for splits of the SNLI dataset. This is the simplest way to use the dataset, and assumes common defaults for field, vocabulary, and iterator parameters. ...
python
def iters(cls, batch_size=32, device=0, root='.data', vectors=None, trees=False, **kwargs): """Create iterator objects for splits of the SNLI dataset. This is the simplest way to use the dataset, and assumes common defaults for field, vocabulary, and iterator parameters. ...
[ "def", "iters", "(", "cls", ",", "batch_size", "=", "32", ",", "device", "=", "0", ",", "root", "=", "'.data'", ",", "vectors", "=", "None", ",", "trees", "=", "False", ",", "*", "*", "kwargs", ")", ":", "if", "trees", ":", "TEXT", "=", "ParsedTe...
Create iterator objects for splits of the SNLI dataset. This is the simplest way to use the dataset, and assumes common defaults for field, vocabulary, and iterator parameters. Arguments: batch_size: Batch size. device: Device to create batches on. Use -1 for CPU and No...
[ "Create", "iterator", "objects", "for", "splits", "of", "the", "SNLI", "dataset", "." ]
26bfce6869dc704f1d86792f9a681d453d7e7bb8
https://github.com/pytorch/text/blob/26bfce6869dc704f1d86792f9a681d453d7e7bb8/torchtext/datasets/nli.py#L91-L126
train
Create iterator objects for splits of the SNLI dataset.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
sripathikrishnan/redis-rdb-tools
rdbtools/encodehelpers.py
bytes_to_unicode
def bytes_to_unicode(byte_data, escape, skip_printable=False): """ Decode given bytes using specified escaping method. :param byte_data: The byte-like object with bytes to decode. :param escape: The escape method to use. :param skip_printable: If True, don't escape byte_data with all 'printable ASCI...
python
def bytes_to_unicode(byte_data, escape, skip_printable=False): """ Decode given bytes using specified escaping method. :param byte_data: The byte-like object with bytes to decode. :param escape: The escape method to use. :param skip_printable: If True, don't escape byte_data with all 'printable ASCI...
[ "def", "bytes_to_unicode", "(", "byte_data", ",", "escape", ",", "skip_printable", "=", "False", ")", ":", "if", "isnumber", "(", "byte_data", ")", ":", "if", "skip_printable", ":", "return", "num2unistr", "(", "byte_data", ")", "else", ":", "byte_data", "="...
Decode given bytes using specified escaping method. :param byte_data: The byte-like object with bytes to decode. :param escape: The escape method to use. :param skip_printable: If True, don't escape byte_data with all 'printable ASCII' bytes. Defaults to False. :return: New unicode string, escaped with ...
[ "Decode", "given", "bytes", "using", "specified", "escaping", "method", ".", ":", "param", "byte_data", ":", "The", "byte", "-", "like", "object", "with", "bytes", "to", "decode", ".", ":", "param", "escape", ":", "The", "escape", "method", "to", "use", ...
543a73e84702e911ddcd31325ecfde77d7fd230b
https://github.com/sripathikrishnan/redis-rdb-tools/blob/543a73e84702e911ddcd31325ecfde77d7fd230b/rdbtools/encodehelpers.py#L96-L123
train
Decode given bytes using specified escaping method.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
sripathikrishnan/redis-rdb-tools
rdbtools/encodehelpers.py
apply_escape_bytes
def apply_escape_bytes(byte_data, escape, skip_printable=False): """ Apply the specified escape method on the given bytes. :param byte_data: The byte-like object with bytes to escape. :param escape: The escape method to use. :param skip_printable: If True, don't escape byte_data with all 'printable ...
python
def apply_escape_bytes(byte_data, escape, skip_printable=False): """ Apply the specified escape method on the given bytes. :param byte_data: The byte-like object with bytes to escape. :param escape: The escape method to use. :param skip_printable: If True, don't escape byte_data with all 'printable ...
[ "def", "apply_escape_bytes", "(", "byte_data", ",", "escape", ",", "skip_printable", "=", "False", ")", ":", "if", "isnumber", "(", "byte_data", ")", ":", "if", "skip_printable", ":", "return", "num2bytes", "(", "byte_data", ")", "else", ":", "byte_data", "=...
Apply the specified escape method on the given bytes. :param byte_data: The byte-like object with bytes to escape. :param escape: The escape method to use. :param skip_printable: If True, don't escape byte_data with all 'printable ASCII' bytes. Defaults to False. :return: new bytes object with the escap...
[ "Apply", "the", "specified", "escape", "method", "on", "the", "given", "bytes", ".", ":", "param", "byte_data", ":", "The", "byte", "-", "like", "object", "with", "bytes", "to", "escape", ".", ":", "param", "escape", ":", "The", "escape", "method", "to",...
543a73e84702e911ddcd31325ecfde77d7fd230b
https://github.com/sripathikrishnan/redis-rdb-tools/blob/543a73e84702e911ddcd31325ecfde77d7fd230b/rdbtools/encodehelpers.py#L126-L154
train
Apply the specified escape method on the given byte - like object with bytes.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
sripathikrishnan/redis-rdb-tools
rdbtools/parser.py
RdbParser._decode_module_id
def _decode_module_id(self, module_id): """ decode module id to string based on @antirez moduleTypeNameByID function from redis/src/module.c :param module_id: 64bit integer :return: string """ name = [''] * 9 module_id >>= 10 for i in reversed(rang...
python
def _decode_module_id(self, module_id): """ decode module id to string based on @antirez moduleTypeNameByID function from redis/src/module.c :param module_id: 64bit integer :return: string """ name = [''] * 9 module_id >>= 10 for i in reversed(rang...
[ "def", "_decode_module_id", "(", "self", ",", "module_id", ")", ":", "name", "=", "[", "''", "]", "*", "9", "module_id", ">>=", "10", "for", "i", "in", "reversed", "(", "range", "(", "9", ")", ")", ":", "name", "[", "i", "]", "=", "self", ".", ...
decode module id to string based on @antirez moduleTypeNameByID function from redis/src/module.c :param module_id: 64bit integer :return: string
[ "decode", "module", "id", "to", "string", "based", "on" ]
543a73e84702e911ddcd31325ecfde77d7fd230b
https://github.com/sripathikrishnan/redis-rdb-tools/blob/543a73e84702e911ddcd31325ecfde77d7fd230b/rdbtools/parser.py#L941-L953
train
decode module id to string based on @antirez moduleTypeNameByID function from redis / src / module. c
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
waleedka/hiddenlayer
hiddenlayer/history.py
format_step
def format_step(step, zero_prefix=False): """Return the step value in format suitable for display.""" if isinstance(step, int): return "{:06}".format(step) if zero_prefix else "{}".format(step) elif isinstance(step, tuple): return "{:04}:{:06}".format(*step) if zero_prefix else "{}:{}".forma...
python
def format_step(step, zero_prefix=False): """Return the step value in format suitable for display.""" if isinstance(step, int): return "{:06}".format(step) if zero_prefix else "{}".format(step) elif isinstance(step, tuple): return "{:04}:{:06}".format(*step) if zero_prefix else "{}:{}".forma...
[ "def", "format_step", "(", "step", ",", "zero_prefix", "=", "False", ")", ":", "if", "isinstance", "(", "step", ",", "int", ")", ":", "return", "\"{:06}\"", ".", "format", "(", "step", ")", "if", "zero_prefix", "else", "\"{}\"", ".", "format", "(", "st...
Return the step value in format suitable for display.
[ "Return", "the", "step", "value", "in", "format", "suitable", "for", "display", "." ]
294f8732b271cbdd6310c55bdf5ce855cbf61c75
https://github.com/waleedka/hiddenlayer/blob/294f8732b271cbdd6310c55bdf5ce855cbf61c75/hiddenlayer/history.py#L27-L32
train
Return the step value in format suitable for display.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
waleedka/hiddenlayer
hiddenlayer/history.py
History.log
def log(self, step, **kwargs): """Record metrics at a specific step. E.g. my_history.log(34, loss=2.3, accuracy=0.2) Okay to call multiple times for the same step. New values overwrite older ones if they have the same metric name. step: An integer or tuple of integers. If a tu...
python
def log(self, step, **kwargs): """Record metrics at a specific step. E.g. my_history.log(34, loss=2.3, accuracy=0.2) Okay to call multiple times for the same step. New values overwrite older ones if they have the same metric name. step: An integer or tuple of integers. If a tu...
[ "def", "log", "(", "self", ",", "step", ",", "*", "*", "kwargs", ")", ":", "assert", "isinstance", "(", "step", ",", "(", "int", ",", "tuple", ")", ")", ",", "\"Step must be an int or a tuple of two ints\"", "self", ".", "step", "=", "step", "# Any new met...
Record metrics at a specific step. E.g. my_history.log(34, loss=2.3, accuracy=0.2) Okay to call multiple times for the same step. New values overwrite older ones if they have the same metric name. step: An integer or tuple of integers. If a tuple, then the first value is c...
[ "Record", "metrics", "at", "a", "specific", "step", ".", "E", ".", "g", "." ]
294f8732b271cbdd6310c55bdf5ce855cbf61c75
https://github.com/waleedka/hiddenlayer/blob/294f8732b271cbdd6310c55bdf5ce855cbf61c75/hiddenlayer/history.py#L67-L88
train
Record the metrics at a specific step.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
waleedka/hiddenlayer
hiddenlayer/history.py
History.get_total_time
def get_total_time(self): """Returns the total period between when the first and last steps where logged. This usually correspnods to the total training time if there were no gaps in the training. """ first_step = self.steps[0] last_step = self.steps[-1] seconds =...
python
def get_total_time(self): """Returns the total period between when the first and last steps where logged. This usually correspnods to the total training time if there were no gaps in the training. """ first_step = self.steps[0] last_step = self.steps[-1] seconds =...
[ "def", "get_total_time", "(", "self", ")", ":", "first_step", "=", "self", ".", "steps", "[", "0", "]", "last_step", "=", "self", ".", "steps", "[", "-", "1", "]", "seconds", "=", "self", ".", "history", "[", "last_step", "]", "[", "\"__timestamp__\"",...
Returns the total period between when the first and last steps where logged. This usually correspnods to the total training time if there were no gaps in the training.
[ "Returns", "the", "total", "period", "between", "when", "the", "first", "and", "last", "steps", "where", "logged", ".", "This", "usually", "correspnods", "to", "the", "total", "training", "time", "if", "there", "were", "no", "gaps", "in", "the", "training", ...
294f8732b271cbdd6310c55bdf5ce855cbf61c75
https://github.com/waleedka/hiddenlayer/blob/294f8732b271cbdd6310c55bdf5ce855cbf61c75/hiddenlayer/history.py#L125-L134
train
Returns the total time between when the first and last steps where logged. This usually correspondspnods to the total training time where the training time is logged.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
waleedka/hiddenlayer
hiddenlayer/graph.py
Graph.outgoing
def outgoing(self, node): """Returns nodes connecting out of the given node (or list of nodes).""" nodes = node if isinstance(node, list) else [node] node_ids = [self.id(n) for n in nodes] # Find edges outgoing from this group but not incoming to it outgoing = [self[e[1]] for e i...
python
def outgoing(self, node): """Returns nodes connecting out of the given node (or list of nodes).""" nodes = node if isinstance(node, list) else [node] node_ids = [self.id(n) for n in nodes] # Find edges outgoing from this group but not incoming to it outgoing = [self[e[1]] for e i...
[ "def", "outgoing", "(", "self", ",", "node", ")", ":", "nodes", "=", "node", "if", "isinstance", "(", "node", ",", "list", ")", "else", "[", "node", "]", "node_ids", "=", "[", "self", ".", "id", "(", "n", ")", "for", "n", "in", "nodes", "]", "#...
Returns nodes connecting out of the given node (or list of nodes).
[ "Returns", "nodes", "connecting", "out", "of", "the", "given", "node", "(", "or", "list", "of", "nodes", ")", "." ]
294f8732b271cbdd6310c55bdf5ce855cbf61c75
https://github.com/waleedka/hiddenlayer/blob/294f8732b271cbdd6310c55bdf5ce855cbf61c75/hiddenlayer/graph.py#L221-L228
train
Returns nodes connecting out of the given node or list of nodes.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
waleedka/hiddenlayer
hiddenlayer/graph.py
Graph.siblings
def siblings(self, node): """Returns all nodes that share the same parent (incoming node) with the given node, including the node itself. """ incoming = self.incoming(node) # TODO: Not handling the case of multiple incoming nodes yet if len(incoming) == 1: inc...
python
def siblings(self, node): """Returns all nodes that share the same parent (incoming node) with the given node, including the node itself. """ incoming = self.incoming(node) # TODO: Not handling the case of multiple incoming nodes yet if len(incoming) == 1: inc...
[ "def", "siblings", "(", "self", ",", "node", ")", ":", "incoming", "=", "self", ".", "incoming", "(", "node", ")", "# TODO: Not handling the case of multiple incoming nodes yet", "if", "len", "(", "incoming", ")", "==", "1", ":", "incoming", "=", "incoming", "...
Returns all nodes that share the same parent (incoming node) with the given node, including the node itself.
[ "Returns", "all", "nodes", "that", "share", "the", "same", "parent", "(", "incoming", "node", ")", "with", "the", "given", "node", "including", "the", "node", "itself", "." ]
294f8732b271cbdd6310c55bdf5ce855cbf61c75
https://github.com/waleedka/hiddenlayer/blob/294f8732b271cbdd6310c55bdf5ce855cbf61c75/hiddenlayer/graph.py#L239-L250
train
Returns all nodes that share the same parent with the given node including the itself.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
waleedka/hiddenlayer
hiddenlayer/graph.py
Graph.remove
def remove(self, nodes): """Remove a node and its edges.""" nodes = nodes if isinstance(nodes, list) else [nodes] for node in nodes: k = self.id(node) self.edges = list(filter(lambda e: e[0] != k and e[1] != k, self.edges)) del self.nodes[k]
python
def remove(self, nodes): """Remove a node and its edges.""" nodes = nodes if isinstance(nodes, list) else [nodes] for node in nodes: k = self.id(node) self.edges = list(filter(lambda e: e[0] != k and e[1] != k, self.edges)) del self.nodes[k]
[ "def", "remove", "(", "self", ",", "nodes", ")", ":", "nodes", "=", "nodes", "if", "isinstance", "(", "nodes", ",", "list", ")", "else", "[", "nodes", "]", "for", "node", "in", "nodes", ":", "k", "=", "self", ".", "id", "(", "node", ")", "self", ...
Remove a node and its edges.
[ "Remove", "a", "node", "and", "its", "edges", "." ]
294f8732b271cbdd6310c55bdf5ce855cbf61c75
https://github.com/waleedka/hiddenlayer/blob/294f8732b271cbdd6310c55bdf5ce855cbf61c75/hiddenlayer/graph.py#L258-L264
train
Remove a node and its edges.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
waleedka/hiddenlayer
hiddenlayer/graph.py
Graph.search
def search(self, pattern): """Searches the graph for a sub-graph that matches the given pattern and returns the first match it finds. """ for node in self.nodes.values(): match, following = pattern.match(self, node) if match: return match, followin...
python
def search(self, pattern): """Searches the graph for a sub-graph that matches the given pattern and returns the first match it finds. """ for node in self.nodes.values(): match, following = pattern.match(self, node) if match: return match, followin...
[ "def", "search", "(", "self", ",", "pattern", ")", ":", "for", "node", "in", "self", ".", "nodes", ".", "values", "(", ")", ":", "match", ",", "following", "=", "pattern", ".", "match", "(", "self", ",", "node", ")", "if", "match", ":", "return", ...
Searches the graph for a sub-graph that matches the given pattern and returns the first match it finds.
[ "Searches", "the", "graph", "for", "a", "sub", "-", "graph", "that", "matches", "the", "given", "pattern", "and", "returns", "the", "first", "match", "it", "finds", "." ]
294f8732b271cbdd6310c55bdf5ce855cbf61c75
https://github.com/waleedka/hiddenlayer/blob/294f8732b271cbdd6310c55bdf5ce855cbf61c75/hiddenlayer/graph.py#L288-L296
train
Searches the graph for a sub - graph that matches the given pattern . Returns a list of the first match it finds.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
waleedka/hiddenlayer
hiddenlayer/graph.py
Graph.sequence_id
def sequence_id(self, sequence): """Make up an ID for a sequence (list) of nodes. Note: `getrandbits()` is very uninformative as a "readable" ID. Here, we build a name such that when the mouse hovers over the drawn node in Jupyter, one can figure out which original nodes make up the sequ...
python
def sequence_id(self, sequence): """Make up an ID for a sequence (list) of nodes. Note: `getrandbits()` is very uninformative as a "readable" ID. Here, we build a name such that when the mouse hovers over the drawn node in Jupyter, one can figure out which original nodes make up the sequ...
[ "def", "sequence_id", "(", "self", ",", "sequence", ")", ":", "if", "self", ".", "meaningful_ids", ":", "# TODO: This might fail if the ID becomes too long", "return", "\"><\"", ".", "join", "(", "[", "node", ".", "id", "for", "node", "in", "sequence", "]", ")...
Make up an ID for a sequence (list) of nodes. Note: `getrandbits()` is very uninformative as a "readable" ID. Here, we build a name such that when the mouse hovers over the drawn node in Jupyter, one can figure out which original nodes make up the sequence. This is actually quite useful.
[ "Make", "up", "an", "ID", "for", "a", "sequence", "(", "list", ")", "of", "nodes", ".", "Note", ":", "getrandbits", "()", "is", "very", "uninformative", "as", "a", "readable", "ID", ".", "Here", "we", "build", "a", "name", "such", "that", "when", "th...
294f8732b271cbdd6310c55bdf5ce855cbf61c75
https://github.com/waleedka/hiddenlayer/blob/294f8732b271cbdd6310c55bdf5ce855cbf61c75/hiddenlayer/graph.py#L299-L309
train
Make up an ID for a sequence of nodes.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
waleedka/hiddenlayer
hiddenlayer/graph.py
Graph.build_dot
def build_dot(self): """Generate a GraphViz Dot graph. Returns a GraphViz Digraph object. """ from graphviz import Digraph # Build GraphViz Digraph dot = Digraph() dot.attr("graph", bgcolor=self.theme["background_color"], color...
python
def build_dot(self): """Generate a GraphViz Dot graph. Returns a GraphViz Digraph object. """ from graphviz import Digraph # Build GraphViz Digraph dot = Digraph() dot.attr("graph", bgcolor=self.theme["background_color"], color...
[ "def", "build_dot", "(", "self", ")", ":", "from", "graphviz", "import", "Digraph", "# Build GraphViz Digraph", "dot", "=", "Digraph", "(", ")", "dot", ".", "attr", "(", "\"graph\"", ",", "bgcolor", "=", "self", ".", "theme", "[", "\"background_color\"", "]"...
Generate a GraphViz Dot graph. Returns a GraphViz Digraph object.
[ "Generate", "a", "GraphViz", "Dot", "graph", "." ]
294f8732b271cbdd6310c55bdf5ce855cbf61c75
https://github.com/waleedka/hiddenlayer/blob/294f8732b271cbdd6310c55bdf5ce855cbf61c75/hiddenlayer/graph.py#L311-L355
train
Generate a GraphViz Dot object.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
waleedka/hiddenlayer
hiddenlayer/utils.py
to_data
def to_data(value): """Standardize data types. Converts PyTorch tensors to Numpy arrays, and Numpy scalars to Python scalars.""" # TODO: Use get_framework() for better detection. if value.__class__.__module__.startswith("torch"): import torch if isinstance(value, torch.nn.parameter.Param...
python
def to_data(value): """Standardize data types. Converts PyTorch tensors to Numpy arrays, and Numpy scalars to Python scalars.""" # TODO: Use get_framework() for better detection. if value.__class__.__module__.startswith("torch"): import torch if isinstance(value, torch.nn.parameter.Param...
[ "def", "to_data", "(", "value", ")", ":", "# TODO: Use get_framework() for better detection.", "if", "value", ".", "__class__", ".", "__module__", ".", "startswith", "(", "\"torch\"", ")", ":", "import", "torch", "if", "isinstance", "(", "value", ",", "torch", "...
Standardize data types. Converts PyTorch tensors to Numpy arrays, and Numpy scalars to Python scalars.
[ "Standardize", "data", "types", ".", "Converts", "PyTorch", "tensors", "to", "Numpy", "arrays", "and", "Numpy", "scalars", "to", "Python", "scalars", "." ]
294f8732b271cbdd6310c55bdf5ce855cbf61c75
https://github.com/waleedka/hiddenlayer/blob/294f8732b271cbdd6310c55bdf5ce855cbf61c75/hiddenlayer/utils.py#L17-L35
train
Standardize data types. Converts PyTorch tensors to Numpy arrays and Numpy scalars to Python scalars.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
waleedka/hiddenlayer
hiddenlayer/utils.py
write
def write(*args): """Like print(), but recognizes tensors and arrays and show more details about them. Example: hl.write("My Tensor", my_tensor) Prints: My Tensor float32 (10, 3, 224, 224) min: 0.0 max: 1.0 """ s = "" for a in args: # Convert tensors ...
python
def write(*args): """Like print(), but recognizes tensors and arrays and show more details about them. Example: hl.write("My Tensor", my_tensor) Prints: My Tensor float32 (10, 3, 224, 224) min: 0.0 max: 1.0 """ s = "" for a in args: # Convert tensors ...
[ "def", "write", "(", "*", "args", ")", ":", "s", "=", "\"\"", "for", "a", "in", "args", ":", "# Convert tensors to Numpy arrays", "a", "=", "to_data", "(", "a", ")", "if", "isinstance", "(", "a", ",", "np", ".", "ndarray", ")", ":", "# Numpy Array", ...
Like print(), but recognizes tensors and arrays and show more details about them. Example: hl.write("My Tensor", my_tensor) Prints: My Tensor float32 (10, 3, 224, 224) min: 0.0 max: 1.0
[ "Like", "print", "()", "but", "recognizes", "tensors", "and", "arrays", "and", "show", "more", "details", "about", "them", "." ]
294f8732b271cbdd6310c55bdf5ce855cbf61c75
https://github.com/waleedka/hiddenlayer/blob/294f8732b271cbdd6310c55bdf5ce855cbf61c75/hiddenlayer/utils.py#L38-L64
train
Like print but recognizes tensors and arrays and show more details about them.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
waleedka/hiddenlayer
hiddenlayer/canvas.py
norm
def norm(image): """Normalize an image to [0, 1] range.""" min_value = image.min() max_value = image.max() if min_value == max_value: return image - min_value return (image - min_value) / (max_value - min_value)
python
def norm(image): """Normalize an image to [0, 1] range.""" min_value = image.min() max_value = image.max() if min_value == max_value: return image - min_value return (image - min_value) / (max_value - min_value)
[ "def", "norm", "(", "image", ")", ":", "min_value", "=", "image", ".", "min", "(", ")", "max_value", "=", "image", ".", "max", "(", ")", "if", "min_value", "==", "max_value", ":", "return", "image", "-", "min_value", "return", "(", "image", "-", "min...
Normalize an image to [0, 1] range.
[ "Normalize", "an", "image", "to", "[", "0", "1", "]", "range", "." ]
294f8732b271cbdd6310c55bdf5ce855cbf61c75
https://github.com/waleedka/hiddenlayer/blob/294f8732b271cbdd6310c55bdf5ce855cbf61c75/hiddenlayer/canvas.py#L27-L33
train
Normalize an image to [ 0 1 ) range.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
waleedka/hiddenlayer
hiddenlayer/canvas.py
show_images
def show_images(images, titles=None, cols=5, **kwargs): """ images: A list of images. I can be either: - A list of Numpy arrays. Each array represents an image. - A list of lists of Numpy arrays. In this case, the images in the inner lists are concatentated to make one image. """ ...
python
def show_images(images, titles=None, cols=5, **kwargs): """ images: A list of images. I can be either: - A list of Numpy arrays. Each array represents an image. - A list of lists of Numpy arrays. In this case, the images in the inner lists are concatentated to make one image. """ ...
[ "def", "show_images", "(", "images", ",", "titles", "=", "None", ",", "cols", "=", "5", ",", "*", "*", "kwargs", ")", ":", "# The images param can be a list or an array", "titles", "=", "titles", "or", "[", "\"\"", "]", "*", "len", "(", "images", ")", "r...
images: A list of images. I can be either: - A list of Numpy arrays. Each array represents an image. - A list of lists of Numpy arrays. In this case, the images in the inner lists are concatentated to make one image.
[ "images", ":", "A", "list", "of", "images", ".", "I", "can", "be", "either", ":", "-", "A", "list", "of", "Numpy", "arrays", ".", "Each", "array", "represents", "an", "image", ".", "-", "A", "list", "of", "lists", "of", "Numpy", "arrays", ".", "In"...
294f8732b271cbdd6310c55bdf5ce855cbf61c75
https://github.com/waleedka/hiddenlayer/blob/294f8732b271cbdd6310c55bdf5ce855cbf61c75/hiddenlayer/canvas.py#L37-L63
train
Show the images in a single order tree structure.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
waleedka/hiddenlayer
hiddenlayer/canvas.py
Canvas.draw_summary
def draw_summary(self, history, title=""): """Inserts a text summary at the top that lists the number of steps and total training time.""" # Generate summary string time_str = str(history.get_total_time()).split(".")[0] # remove microseconds summary = "Step: {} Time: {}".fo...
python
def draw_summary(self, history, title=""): """Inserts a text summary at the top that lists the number of steps and total training time.""" # Generate summary string time_str = str(history.get_total_time()).split(".")[0] # remove microseconds summary = "Step: {} Time: {}".fo...
[ "def", "draw_summary", "(", "self", ",", "history", ",", "title", "=", "\"\"", ")", ":", "# Generate summary string", "time_str", "=", "str", "(", "history", ".", "get_total_time", "(", ")", ")", ".", "split", "(", "\".\"", ")", "[", "0", "]", "# remove ...
Inserts a text summary at the top that lists the number of steps and total training time.
[ "Inserts", "a", "text", "summary", "at", "the", "top", "that", "lists", "the", "number", "of", "steps", "and", "total", "training", "time", "." ]
294f8732b271cbdd6310c55bdf5ce855cbf61c75
https://github.com/waleedka/hiddenlayer/blob/294f8732b271cbdd6310c55bdf5ce855cbf61c75/hiddenlayer/canvas.py#L161-L169
train
Inserts a text summary at the top that lists the number of steps and total training time.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
waleedka/hiddenlayer
hiddenlayer/canvas.py
Canvas.draw_plot
def draw_plot(self, metrics, labels=None, ylabel=""): """ metrics: One or more metrics parameters. Each represents the history of one metric. """ metrics = metrics if isinstance(metrics, list) else [metrics] # Loop through metrics title = "" for i, m i...
python
def draw_plot(self, metrics, labels=None, ylabel=""): """ metrics: One or more metrics parameters. Each represents the history of one metric. """ metrics = metrics if isinstance(metrics, list) else [metrics] # Loop through metrics title = "" for i, m i...
[ "def", "draw_plot", "(", "self", ",", "metrics", ",", "labels", "=", "None", ",", "ylabel", "=", "\"\"", ")", ":", "metrics", "=", "metrics", "if", "isinstance", "(", "metrics", ",", "list", ")", "else", "[", "metrics", "]", "# Loop through metrics", "ti...
metrics: One or more metrics parameters. Each represents the history of one metric.
[ "metrics", ":", "One", "or", "more", "metrics", "parameters", ".", "Each", "represents", "the", "history", "of", "one", "metric", "." ]
294f8732b271cbdd6310c55bdf5ce855cbf61c75
https://github.com/waleedka/hiddenlayer/blob/294f8732b271cbdd6310c55bdf5ce855cbf61c75/hiddenlayer/canvas.py#L171-L188
train
Draws the history of the entries in the given metrics.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
waleedka/hiddenlayer
hiddenlayer/canvas.py
Canvas.draw_image
def draw_image(self, metric, limit=5): """Display a series of images at different time steps.""" rows = 1 cols = limit self.ax.axis("off") # Take the Axes gridspec and divide it into a grid gs = matplotlib.gridspec.GridSpecFromSubplotSpec( rows, cols, subplot_...
python
def draw_image(self, metric, limit=5): """Display a series of images at different time steps.""" rows = 1 cols = limit self.ax.axis("off") # Take the Axes gridspec and divide it into a grid gs = matplotlib.gridspec.GridSpecFromSubplotSpec( rows, cols, subplot_...
[ "def", "draw_image", "(", "self", ",", "metric", ",", "limit", "=", "5", ")", ":", "rows", "=", "1", "cols", "=", "limit", "self", ".", "ax", ".", "axis", "(", "\"off\"", ")", "# Take the Axes gridspec and divide it into a grid", "gs", "=", "matplotlib", "...
Display a series of images at different time steps.
[ "Display", "a", "series", "of", "images", "at", "different", "time", "steps", "." ]
294f8732b271cbdd6310c55bdf5ce855cbf61c75
https://github.com/waleedka/hiddenlayer/blob/294f8732b271cbdd6310c55bdf5ce855cbf61c75/hiddenlayer/canvas.py#L191-L204
train
Display a series of images at different time steps.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
waleedka/hiddenlayer
hiddenlayer/canvas.py
Canvas.draw_hist
def draw_hist(self, metric, title=""): """Draw a series of histograms of the selected keys over different training steps. """ # TODO: assert isinstance(list(values.values())[0], np.ndarray) rows = 1 cols = 1 limit = 10 # max steps to show # We need a 3D...
python
def draw_hist(self, metric, title=""): """Draw a series of histograms of the selected keys over different training steps. """ # TODO: assert isinstance(list(values.values())[0], np.ndarray) rows = 1 cols = 1 limit = 10 # max steps to show # We need a 3D...
[ "def", "draw_hist", "(", "self", ",", "metric", ",", "title", "=", "\"\"", ")", ":", "# TODO: assert isinstance(list(values.values())[0], np.ndarray)", "rows", "=", "1", "cols", "=", "1", "limit", "=", "10", "# max steps to show", "# We need a 3D projection Subplot, so ...
Draw a series of histograms of the selected keys over different training steps.
[ "Draw", "a", "series", "of", "histograms", "of", "the", "selected", "keys", "over", "different", "training", "steps", "." ]
294f8732b271cbdd6310c55bdf5ce855cbf61c75
https://github.com/waleedka/hiddenlayer/blob/294f8732b271cbdd6310c55bdf5ce855cbf61c75/hiddenlayer/canvas.py#L206-L257
train
Draw a series of histograms over the selected keys over different training steps.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
waleedka/hiddenlayer
demos/tf_cifar10.py
CIFAR10._load
def _load(self, dataset='train'): """Load the data in memory. Args: dataset: string in ['train', 'test'] """ data, labels = None, None if dataset is 'train': files = [os.path.join(self.cifar10_dir, 'data_batch_%d' % i) for i in range(1, 6)] else: ...
python
def _load(self, dataset='train'): """Load the data in memory. Args: dataset: string in ['train', 'test'] """ data, labels = None, None if dataset is 'train': files = [os.path.join(self.cifar10_dir, 'data_batch_%d' % i) for i in range(1, 6)] else: ...
[ "def", "_load", "(", "self", ",", "dataset", "=", "'train'", ")", ":", "data", ",", "labels", "=", "None", ",", "None", "if", "dataset", "is", "'train'", ":", "files", "=", "[", "os", ".", "path", ".", "join", "(", "self", ".", "cifar10_dir", ",", ...
Load the data in memory. Args: dataset: string in ['train', 'test']
[ "Load", "the", "data", "in", "memory", ".", "Args", ":", "dataset", ":", "string", "in", "[", "train", "test", "]" ]
294f8732b271cbdd6310c55bdf5ce855cbf61c75
https://github.com/waleedka/hiddenlayer/blob/294f8732b271cbdd6310c55bdf5ce855cbf61c75/demos/tf_cifar10.py#L78-L119
train
Loads the data in memory.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
waleedka/hiddenlayer
demos/tf_cifar10.py
CIFAR10.model
def model(self, inputs, mode='train'): """Build a simple convnet (BN before ReLU). Args: inputs: a tensor of size [batch_size, height, width, channels] mode: string in ['train', 'test'] Returns: the last op containing the predictions Note: ...
python
def model(self, inputs, mode='train'): """Build a simple convnet (BN before ReLU). Args: inputs: a tensor of size [batch_size, height, width, channels] mode: string in ['train', 'test'] Returns: the last op containing the predictions Note: ...
[ "def", "model", "(", "self", ",", "inputs", ",", "mode", "=", "'train'", ")", ":", "# Extract features", "training", "=", "(", "mode", "==", "'train'", ")", "with", "tf", ".", "variable_scope", "(", "'conv1'", ")", "as", "scope", ":", "conv", "=", "tf"...
Build a simple convnet (BN before ReLU). Args: inputs: a tensor of size [batch_size, height, width, channels] mode: string in ['train', 'test'] Returns: the last op containing the predictions Note: Best score Step: 7015 - Epoch: 18/20 ...
[ "Build", "a", "simple", "convnet", "(", "BN", "before", "ReLU", ")", ".", "Args", ":", "inputs", ":", "a", "tensor", "of", "size", "[", "batch_size", "height", "width", "channels", "]", "mode", ":", "string", "in", "[", "train", "test", "]", "Returns",...
294f8732b271cbdd6310c55bdf5ce855cbf61c75
https://github.com/waleedka/hiddenlayer/blob/294f8732b271cbdd6310c55bdf5ce855cbf61c75/demos/tf_cifar10.py#L121-L169
train
Build a simple convnet with the last op containing the predictions.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
waleedka/hiddenlayer
demos/tf_cifar10.py
CIFAR10.maybe_download_and_extract
def maybe_download_and_extract(self): """Download and extract the tarball from Alex Krizhevsky's website.""" if not os.path.exists(self.cifar10_dir): if not os.path.exists(self.data_dir): os.makedirs(self.data_dir) def _progress(count, block_size, total_size): ...
python
def maybe_download_and_extract(self): """Download and extract the tarball from Alex Krizhevsky's website.""" if not os.path.exists(self.cifar10_dir): if not os.path.exists(self.data_dir): os.makedirs(self.data_dir) def _progress(count, block_size, total_size): ...
[ "def", "maybe_download_and_extract", "(", "self", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "self", ".", "cifar10_dir", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "self", ".", "data_dir", ")", ":", "os", ".", ...
Download and extract the tarball from Alex Krizhevsky's website.
[ "Download", "and", "extract", "the", "tarball", "from", "Alex", "Krizhevsky", "s", "website", "." ]
294f8732b271cbdd6310c55bdf5ce855cbf61c75
https://github.com/waleedka/hiddenlayer/blob/294f8732b271cbdd6310c55bdf5ce855cbf61c75/demos/tf_cifar10.py#L215-L232
train
Download and extract the tarball from Alex Krizhevsky s website.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
waleedka/hiddenlayer
hiddenlayer/pytorch_builder.py
dump_pytorch_graph
def dump_pytorch_graph(graph): """List all the nodes in a PyTorch graph.""" f = "{:25} {:40} {} -> {}" print(f.format("kind", "scopeName", "inputs", "outputs")) for node in graph.nodes(): print(f.format(node.kind(), node.scopeName(), [i.unique() for i in node.inputs()], ...
python
def dump_pytorch_graph(graph): """List all the nodes in a PyTorch graph.""" f = "{:25} {:40} {} -> {}" print(f.format("kind", "scopeName", "inputs", "outputs")) for node in graph.nodes(): print(f.format(node.kind(), node.scopeName(), [i.unique() for i in node.inputs()], ...
[ "def", "dump_pytorch_graph", "(", "graph", ")", ":", "f", "=", "\"{:25} {:40} {} -> {}\"", "print", "(", "f", ".", "format", "(", "\"kind\"", ",", "\"scopeName\"", ",", "\"inputs\"", ",", "\"outputs\"", ")", ")", "for", "node", "in", "graph", ".", "nodes",...
List all the nodes in a PyTorch graph.
[ "List", "all", "the", "nodes", "in", "a", "PyTorch", "graph", "." ]
294f8732b271cbdd6310c55bdf5ce855cbf61c75
https://github.com/waleedka/hiddenlayer/blob/294f8732b271cbdd6310c55bdf5ce855cbf61c75/hiddenlayer/pytorch_builder.py#L30-L38
train
List all the nodes in a PyTorch graph.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
waleedka/hiddenlayer
hiddenlayer/pytorch_builder.py
pytorch_id
def pytorch_id(node): """Returns a unique ID for a node.""" # After ONNX simplification, the scopeName is not unique anymore # so append node outputs to guarantee uniqueness return node.scopeName() + "/outputs/" + "/".join([o.uniqueName() for o in node.outputs()])
python
def pytorch_id(node): """Returns a unique ID for a node.""" # After ONNX simplification, the scopeName is not unique anymore # so append node outputs to guarantee uniqueness return node.scopeName() + "/outputs/" + "/".join([o.uniqueName() for o in node.outputs()])
[ "def", "pytorch_id", "(", "node", ")", ":", "# After ONNX simplification, the scopeName is not unique anymore", "# so append node outputs to guarantee uniqueness", "return", "node", ".", "scopeName", "(", ")", "+", "\"/outputs/\"", "+", "\"/\"", ".", "join", "(", "[", "o"...
Returns a unique ID for a node.
[ "Returns", "a", "unique", "ID", "for", "a", "node", "." ]
294f8732b271cbdd6310c55bdf5ce855cbf61c75
https://github.com/waleedka/hiddenlayer/blob/294f8732b271cbdd6310c55bdf5ce855cbf61c75/hiddenlayer/pytorch_builder.py#L41-L45
train
Returns a unique ID for a node.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
waleedka/hiddenlayer
hiddenlayer/pytorch_builder.py
get_shape
def get_shape(torch_node): """Return the output shape of the given Pytorch node.""" # Extract node output shape from the node string representation # This is a hack because there doesn't seem to be an official way to do it. # See my quesiton in the PyTorch forum: # https://discuss.pytorch.org/t/node...
python
def get_shape(torch_node): """Return the output shape of the given Pytorch node.""" # Extract node output shape from the node string representation # This is a hack because there doesn't seem to be an official way to do it. # See my quesiton in the PyTorch forum: # https://discuss.pytorch.org/t/node...
[ "def", "get_shape", "(", "torch_node", ")", ":", "# Extract node output shape from the node string representation", "# This is a hack because there doesn't seem to be an official way to do it.", "# See my quesiton in the PyTorch forum:", "# https://discuss.pytorch.org/t/node-output-shape-from-trac...
Return the output shape of the given Pytorch node.
[ "Return", "the", "output", "shape", "of", "the", "given", "Pytorch", "node", "." ]
294f8732b271cbdd6310c55bdf5ce855cbf61c75
https://github.com/waleedka/hiddenlayer/blob/294f8732b271cbdd6310c55bdf5ce855cbf61c75/hiddenlayer/pytorch_builder.py#L48-L63
train
Return the output shape of the given Pytorch node.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
waleedka/hiddenlayer
hiddenlayer/tf_builder.py
dump_tf_graph
def dump_tf_graph(tfgraph, tfgraphdef): """List all the nodes in a TF graph. tfgraph: A TF Graph object. tfgraphdef: A TF GraphDef object. """ print("Nodes ({})".format(len(tfgraphdef.node))) f = "{:15} {:59} {:20} {}" print(f.format("kind", "scopeName", "shape", "inputs")) for node in t...
python
def dump_tf_graph(tfgraph, tfgraphdef): """List all the nodes in a TF graph. tfgraph: A TF Graph object. tfgraphdef: A TF GraphDef object. """ print("Nodes ({})".format(len(tfgraphdef.node))) f = "{:15} {:59} {:20} {}" print(f.format("kind", "scopeName", "shape", "inputs")) for node in t...
[ "def", "dump_tf_graph", "(", "tfgraph", ",", "tfgraphdef", ")", ":", "print", "(", "\"Nodes ({})\"", ".", "format", "(", "len", "(", "tfgraphdef", ".", "node", ")", ")", ")", "f", "=", "\"{:15} {:59} {:20} {}\"", "print", "(", "f", ".", "format", "(", "\...
List all the nodes in a TF graph. tfgraph: A TF Graph object. tfgraphdef: A TF GraphDef object.
[ "List", "all", "the", "nodes", "in", "a", "TF", "graph", ".", "tfgraph", ":", "A", "TF", "Graph", "object", ".", "tfgraphdef", ":", "A", "TF", "GraphDef", "object", "." ]
294f8732b271cbdd6310c55bdf5ce855cbf61c75
https://github.com/waleedka/hiddenlayer/blob/294f8732b271cbdd6310c55bdf5ce855cbf61c75/hiddenlayer/tf_builder.py#L46-L59
train
Dump a TF graph to stdout.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
waleedka/hiddenlayer
hiddenlayer/tf_builder.py
import_graph
def import_graph(hl_graph, tf_graph, output=None, verbose=False): """Convert TF graph to directed graph tfgraph: A TF Graph object. output: Name of the output node (string). verbose: Set to True for debug print output """ # Get clean(er) list of nodes graph_def = tf_graph.as_graph_def(add_sh...
python
def import_graph(hl_graph, tf_graph, output=None, verbose=False): """Convert TF graph to directed graph tfgraph: A TF Graph object. output: Name of the output node (string). verbose: Set to True for debug print output """ # Get clean(er) list of nodes graph_def = tf_graph.as_graph_def(add_sh...
[ "def", "import_graph", "(", "hl_graph", ",", "tf_graph", ",", "output", "=", "None", ",", "verbose", "=", "False", ")", ":", "# Get clean(er) list of nodes", "graph_def", "=", "tf_graph", ".", "as_graph_def", "(", "add_shapes", "=", "True", ")", "graph_def", "...
Convert TF graph to directed graph tfgraph: A TF Graph object. output: Name of the output node (string). verbose: Set to True for debug print output
[ "Convert", "TF", "graph", "to", "directed", "graph", "tfgraph", ":", "A", "TF", "Graph", "object", ".", "output", ":", "Name", "of", "the", "output", "node", "(", "string", ")", ".", "verbose", ":", "Set", "to", "True", "for", "debug", "print", "output...
294f8732b271cbdd6310c55bdf5ce855cbf61c75
https://github.com/waleedka/hiddenlayer/blob/294f8732b271cbdd6310c55bdf5ce855cbf61c75/hiddenlayer/tf_builder.py#L62-L95
train
Convert a TF graph to a directed graph.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
dpkp/kafka-python
kafka/consumer/fetcher.py
Fetcher.send_fetches
def send_fetches(self): """Send FetchRequests for all assigned partitions that do not already have an in-flight fetch or pending fetch data. Returns: List of Futures: each future resolves to a FetchResponse """ futures = [] for node_id, request in six.iterite...
python
def send_fetches(self): """Send FetchRequests for all assigned partitions that do not already have an in-flight fetch or pending fetch data. Returns: List of Futures: each future resolves to a FetchResponse """ futures = [] for node_id, request in six.iterite...
[ "def", "send_fetches", "(", "self", ")", ":", "futures", "=", "[", "]", "for", "node_id", ",", "request", "in", "six", ".", "iteritems", "(", "self", ".", "_create_fetch_requests", "(", ")", ")", ":", "if", "self", ".", "_client", ".", "ready", "(", ...
Send FetchRequests for all assigned partitions that do not already have an in-flight fetch or pending fetch data. Returns: List of Futures: each future resolves to a FetchResponse
[ "Send", "FetchRequests", "for", "all", "assigned", "partitions", "that", "do", "not", "already", "have", "an", "in", "-", "flight", "fetch", "or", "pending", "fetch", "data", "." ]
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/consumer/fetcher.py#L115-L132
train
Send FetchRequests for all assigned partitions that do not already have an in - flight fetch or pending fetch data. Returns a list of Futures that resolves to a FetchResponse
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
dpkp/kafka-python
kafka/consumer/fetcher.py
Fetcher.reset_offsets_if_needed
def reset_offsets_if_needed(self, partitions): """Lookup and set offsets for any partitions which are awaiting an explicit reset. Arguments: partitions (set of TopicPartitions): the partitions to reset """ for tp in partitions: # TODO: If there are severa...
python
def reset_offsets_if_needed(self, partitions): """Lookup and set offsets for any partitions which are awaiting an explicit reset. Arguments: partitions (set of TopicPartitions): the partitions to reset """ for tp in partitions: # TODO: If there are severa...
[ "def", "reset_offsets_if_needed", "(", "self", ",", "partitions", ")", ":", "for", "tp", "in", "partitions", ":", "# TODO: If there are several offsets to reset, we could submit offset requests in parallel", "if", "self", ".", "_subscriptions", ".", "is_assigned", "(", "tp"...
Lookup and set offsets for any partitions which are awaiting an explicit reset. Arguments: partitions (set of TopicPartitions): the partitions to reset
[ "Lookup", "and", "set", "offsets", "for", "any", "partitions", "which", "are", "awaiting", "an", "explicit", "reset", "." ]
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/consumer/fetcher.py#L134-L144
train
Reset offsets for any partitions which are awaiting an explicit reset.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
dpkp/kafka-python
kafka/consumer/fetcher.py
Fetcher.update_fetch_positions
def update_fetch_positions(self, partitions): """Update the fetch positions for the provided partitions. Arguments: partitions (list of TopicPartitions): partitions to update Raises: NoOffsetForPartitionError: if no offset is stored for a given partition...
python
def update_fetch_positions(self, partitions): """Update the fetch positions for the provided partitions. Arguments: partitions (list of TopicPartitions): partitions to update Raises: NoOffsetForPartitionError: if no offset is stored for a given partition...
[ "def", "update_fetch_positions", "(", "self", ",", "partitions", ")", ":", "# reset the fetch position to the committed position", "for", "tp", "in", "partitions", ":", "if", "not", "self", ".", "_subscriptions", ".", "is_assigned", "(", "tp", ")", ":", "log", "."...
Update the fetch positions for the provided partitions. Arguments: partitions (list of TopicPartitions): partitions to update Raises: NoOffsetForPartitionError: if no offset is stored for a given partition and no reset policy is available
[ "Update", "the", "fetch", "positions", "for", "the", "provided", "partitions", "." ]
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/consumer/fetcher.py#L159-L191
train
Updates the fetch positions for the provided partitions.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
dpkp/kafka-python
kafka/consumer/fetcher.py
Fetcher._reset_offset
def _reset_offset(self, partition): """Reset offsets for the given partition using the offset reset strategy. Arguments: partition (TopicPartition): the partition that needs reset offset Raises: NoOffsetForPartitionError: if no offset reset strategy is defined "...
python
def _reset_offset(self, partition): """Reset offsets for the given partition using the offset reset strategy. Arguments: partition (TopicPartition): the partition that needs reset offset Raises: NoOffsetForPartitionError: if no offset reset strategy is defined "...
[ "def", "_reset_offset", "(", "self", ",", "partition", ")", ":", "timestamp", "=", "self", ".", "_subscriptions", ".", "assignment", "[", "partition", "]", ".", "reset_strategy", "if", "timestamp", "is", "OffsetResetStrategy", ".", "EARLIEST", ":", "strategy", ...
Reset offsets for the given partition using the offset reset strategy. Arguments: partition (TopicPartition): the partition that needs reset offset Raises: NoOffsetForPartitionError: if no offset reset strategy is defined
[ "Reset", "offsets", "for", "the", "given", "partition", "using", "the", "offset", "reset", "strategy", "." ]
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/consumer/fetcher.py#L218-L245
train
Reset the offset for the given topic partition.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
dpkp/kafka-python
kafka/consumer/fetcher.py
Fetcher._retrieve_offsets
def _retrieve_offsets(self, timestamps, timeout_ms=float("inf")): """Fetch offset for each partition passed in ``timestamps`` map. Blocks until offsets are obtained, a non-retriable exception is raised or ``timeout_ms`` passed. Arguments: timestamps: {TopicPartition: int} d...
python
def _retrieve_offsets(self, timestamps, timeout_ms=float("inf")): """Fetch offset for each partition passed in ``timestamps`` map. Blocks until offsets are obtained, a non-retriable exception is raised or ``timeout_ms`` passed. Arguments: timestamps: {TopicPartition: int} d...
[ "def", "_retrieve_offsets", "(", "self", ",", "timestamps", ",", "timeout_ms", "=", "float", "(", "\"inf\"", ")", ")", ":", "if", "not", "timestamps", ":", "return", "{", "}", "start_time", "=", "time", ".", "time", "(", ")", "remaining_ms", "=", "timeou...
Fetch offset for each partition passed in ``timestamps`` map. Blocks until offsets are obtained, a non-retriable exception is raised or ``timeout_ms`` passed. Arguments: timestamps: {TopicPartition: int} dict with timestamps to fetch offsets by. -1 for the latest av...
[ "Fetch", "offset", "for", "each", "partition", "passed", "in", "timestamps", "map", "." ]
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/consumer/fetcher.py#L247-L293
train
Fetch offsets for each topic partition passed in timestamps.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
dpkp/kafka-python
kafka/consumer/fetcher.py
Fetcher.fetched_records
def fetched_records(self, max_records=None): """Returns previously fetched records and updates consumed offsets. Arguments: max_records (int): Maximum number of records returned. Defaults to max_poll_records configuration. Raises: OffsetOutOfRangeError: ...
python
def fetched_records(self, max_records=None): """Returns previously fetched records and updates consumed offsets. Arguments: max_records (int): Maximum number of records returned. Defaults to max_poll_records configuration. Raises: OffsetOutOfRangeError: ...
[ "def", "fetched_records", "(", "self", ",", "max_records", "=", "None", ")", ":", "if", "max_records", "is", "None", ":", "max_records", "=", "self", ".", "config", "[", "'max_poll_records'", "]", "assert", "max_records", ">", "0", "drained", "=", "collectio...
Returns previously fetched records and updates consumed offsets. Arguments: max_records (int): Maximum number of records returned. Defaults to max_poll_records configuration. Raises: OffsetOutOfRangeError: if no subscription offset_reset_strategy Cor...
[ "Returns", "previously", "fetched", "records", "and", "updates", "consumed", "offsets", "." ]
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/consumer/fetcher.py#L295-L334
train
Returns previously fetched records and updates consumed offsets.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
dpkp/kafka-python
kafka/consumer/fetcher.py
Fetcher._message_generator
def _message_generator(self): """Iterate over fetched_records""" while self._next_partition_records or self._completed_fetches: if not self._next_partition_records: completion = self._completed_fetches.popleft() self._next_partition_records = self._parse_fetc...
python
def _message_generator(self): """Iterate over fetched_records""" while self._next_partition_records or self._completed_fetches: if not self._next_partition_records: completion = self._completed_fetches.popleft() self._next_partition_records = self._parse_fetc...
[ "def", "_message_generator", "(", "self", ")", ":", "while", "self", ".", "_next_partition_records", "or", "self", ".", "_completed_fetches", ":", "if", "not", "self", ".", "_next_partition_records", ":", "completion", "=", "self", ".", "_completed_fetches", ".", ...
Iterate over fetched_records
[ "Iterate", "over", "fetched_records" ]
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/consumer/fetcher.py#L382-L436
train
Iterate over fetched_records and yield messages from the broker.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
dpkp/kafka-python
kafka/consumer/fetcher.py
Fetcher._send_offset_requests
def _send_offset_requests(self, timestamps): """Fetch offsets for each partition in timestamps dict. This may send request to multiple nodes, based on who is Leader for partition. Arguments: timestamps (dict): {TopicPartition: int} mapping of fetching timestamps. ...
python
def _send_offset_requests(self, timestamps): """Fetch offsets for each partition in timestamps dict. This may send request to multiple nodes, based on who is Leader for partition. Arguments: timestamps (dict): {TopicPartition: int} mapping of fetching timestamps. ...
[ "def", "_send_offset_requests", "(", "self", ",", "timestamps", ")", ":", "timestamps_by_node", "=", "collections", ".", "defaultdict", "(", "dict", ")", "for", "partition", ",", "timestamp", "in", "six", ".", "iteritems", "(", "timestamps", ")", ":", "node_id...
Fetch offsets for each partition in timestamps dict. This may send request to multiple nodes, based on who is Leader for partition. Arguments: timestamps (dict): {TopicPartition: int} mapping of fetching timestamps. Returns: Future: resolves to a mapping...
[ "Fetch", "offsets", "for", "each", "partition", "in", "timestamps", "dict", ".", "This", "may", "send", "request", "to", "multiple", "nodes", "based", "on", "who", "is", "Leader", "for", "partition", "." ]
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/consumer/fetcher.py#L494-L542
train
Send offsets for each partition in timestamps dict to each node.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
dpkp/kafka-python
kafka/consumer/fetcher.py
Fetcher._handle_offset_response
def _handle_offset_response(self, future, response): """Callback for the response of the list offset call above. Arguments: future (Future): the future to update based on response response (OffsetResponse): response from the server Raises: AssertionError: if...
python
def _handle_offset_response(self, future, response): """Callback for the response of the list offset call above. Arguments: future (Future): the future to update based on response response (OffsetResponse): response from the server Raises: AssertionError: if...
[ "def", "_handle_offset_response", "(", "self", ",", "future", ",", "response", ")", ":", "timestamp_offset_map", "=", "{", "}", "for", "topic", ",", "part_data", "in", "response", ".", "topics", ":", "for", "partition_info", "in", "part_data", ":", "partition"...
Callback for the response of the list offset call above. Arguments: future (Future): the future to update based on response response (OffsetResponse): response from the server Raises: AssertionError: if response does not match partition
[ "Callback", "for", "the", "response", "of", "the", "list", "offset", "call", "above", "." ]
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/consumer/fetcher.py#L568-L627
train
Callback for the response of the list offset request.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
dpkp/kafka-python
kafka/consumer/fetcher.py
Fetcher._create_fetch_requests
def _create_fetch_requests(self): """Create fetch requests for all assigned partitions, grouped by node. FetchRequests skipped if no leader, or node has requests in flight Returns: dict: {node_id: FetchRequest, ...} (version depends on api_version) """ # create the ...
python
def _create_fetch_requests(self): """Create fetch requests for all assigned partitions, grouped by node. FetchRequests skipped if no leader, or node has requests in flight Returns: dict: {node_id: FetchRequest, ...} (version depends on api_version) """ # create the ...
[ "def", "_create_fetch_requests", "(", "self", ")", ":", "# create the fetch info as a dict of lists of partition info tuples", "# which can be passed to FetchRequest() via .items()", "fetchable", "=", "collections", ".", "defaultdict", "(", "lambda", ":", "collections", ".", "def...
Create fetch requests for all assigned partitions, grouped by node. FetchRequests skipped if no leader, or node has requests in flight Returns: dict: {node_id: FetchRequest, ...} (version depends on api_version)
[ "Create", "fetch", "requests", "for", "all", "assigned", "partitions", "grouped", "by", "node", "." ]
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/consumer/fetcher.py#L640-L729
train
Create fetch requests for all assigned partitions grouped by node.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
dpkp/kafka-python
kafka/consumer/fetcher.py
Fetcher._handle_fetch_response
def _handle_fetch_response(self, request, send_time, response): """The callback for fetch completion""" fetch_offsets = {} for topic, partitions in request.topics: for partition_data in partitions: partition, offset = partition_data[:2] fetch_offsets[T...
python
def _handle_fetch_response(self, request, send_time, response): """The callback for fetch completion""" fetch_offsets = {} for topic, partitions in request.topics: for partition_data in partitions: partition, offset = partition_data[:2] fetch_offsets[T...
[ "def", "_handle_fetch_response", "(", "self", ",", "request", ",", "send_time", ",", "response", ")", ":", "fetch_offsets", "=", "{", "}", "for", "topic", ",", "partitions", "in", "request", ".", "topics", ":", "for", "partition_data", "in", "partitions", ":...
The callback for fetch completion
[ "The", "callback", "for", "fetch", "completion" ]
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/consumer/fetcher.py#L731-L760
train
The callback for fetching a new topic from the server.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
dpkp/kafka-python
kafka/consumer/fetcher.py
FetchResponseMetricAggregator.record
def record(self, partition, num_bytes, num_records): """ After each partition is parsed, we update the current metric totals with the total bytes and number of records parsed. After all partitions have reported, we write the metric. """ self.unrecorded_partitions.remove(p...
python
def record(self, partition, num_bytes, num_records): """ After each partition is parsed, we update the current metric totals with the total bytes and number of records parsed. After all partitions have reported, we write the metric. """ self.unrecorded_partitions.remove(p...
[ "def", "record", "(", "self", ",", "partition", ",", "num_bytes", ",", "num_records", ")", ":", "self", ".", "unrecorded_partitions", ".", "remove", "(", "partition", ")", "self", ".", "total_bytes", "+=", "num_bytes", "self", ".", "total_records", "+=", "nu...
After each partition is parsed, we update the current metric totals with the total bytes and number of records parsed. After all partitions have reported, we write the metric.
[ "After", "each", "partition", "is", "parsed", "we", "update", "the", "current", "metric", "totals", "with", "the", "total", "bytes", "and", "number", "of", "records", "parsed", ".", "After", "all", "partitions", "have", "reported", "we", "write", "the", "met...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/consumer/fetcher.py#L906-L919
train
Record the current metrics for the given partition.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
dpkp/kafka-python
kafka/consumer/base.py
Consumer._auto_commit
def _auto_commit(self): """ Check if we have to commit based on number of messages and commit """ # Check if we are supposed to do an auto-commit if not self.auto_commit or self.auto_commit_every_n is None: return if self.count_since_commit >= self.auto_comm...
python
def _auto_commit(self): """ Check if we have to commit based on number of messages and commit """ # Check if we are supposed to do an auto-commit if not self.auto_commit or self.auto_commit_every_n is None: return if self.count_since_commit >= self.auto_comm...
[ "def", "_auto_commit", "(", "self", ")", ":", "# Check if we are supposed to do an auto-commit", "if", "not", "self", ".", "auto_commit", "or", "self", ".", "auto_commit_every_n", "is", "None", ":", "return", "if", "self", ".", "count_since_commit", ">=", "self", ...
Check if we have to commit based on number of messages and commit
[ "Check", "if", "we", "have", "to", "commit", "based", "on", "number", "of", "messages", "and", "commit" ]
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/consumer/base.py#L172-L182
train
Check if we have to commit based on number of messages and commit
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
dpkp/kafka-python
kafka/consumer/base.py
Consumer.pending
def pending(self, partitions=None): """ Gets the pending message count Keyword Arguments: partitions (list): list of partitions to check for, default is to check all """ if partitions is None: partitions = self.offsets.keys() total = 0 re...
python
def pending(self, partitions=None): """ Gets the pending message count Keyword Arguments: partitions (list): list of partitions to check for, default is to check all """ if partitions is None: partitions = self.offsets.keys() total = 0 re...
[ "def", "pending", "(", "self", ",", "partitions", "=", "None", ")", ":", "if", "partitions", "is", "None", ":", "partitions", "=", "self", ".", "offsets", ".", "keys", "(", ")", "total", "=", "0", "reqs", "=", "[", "]", "for", "partition", "in", "p...
Gets the pending message count Keyword Arguments: partitions (list): list of partitions to check for, default is to check all
[ "Gets", "the", "pending", "message", "count" ]
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/consumer/base.py#L209-L232
train
Gets the number of pending messages for the specified partitions
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
dpkp/kafka-python
kafka/partitioner/hashed.py
murmur2
def murmur2(data): """Pure-python Murmur2 implementation. Based on java client, see org.apache.kafka.common.utils.Utils.murmur2 Args: data (bytes): opaque bytes Returns: MurmurHash2 of data """ # Python2 bytes is really a str, causing the bitwise operations below to fail # so conv...
python
def murmur2(data): """Pure-python Murmur2 implementation. Based on java client, see org.apache.kafka.common.utils.Utils.murmur2 Args: data (bytes): opaque bytes Returns: MurmurHash2 of data """ # Python2 bytes is really a str, causing the bitwise operations below to fail # so conv...
[ "def", "murmur2", "(", "data", ")", ":", "# Python2 bytes is really a str, causing the bitwise operations below to fail", "# so convert to bytearray.", "if", "six", ".", "PY2", ":", "data", "=", "bytearray", "(", "bytes", "(", "data", ")", ")", "length", "=", "len", ...
Pure-python Murmur2 implementation. Based on java client, see org.apache.kafka.common.utils.Utils.murmur2 Args: data (bytes): opaque bytes Returns: MurmurHash2 of data
[ "Pure", "-", "python", "Murmur2", "implementation", "." ]
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/partitioner/hashed.py#L52-L118
train
Pure - python Murmur2 implementation.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
dpkp/kafka-python
kafka/consumer/multiprocess.py
MultiProcessConsumer.get_messages
def get_messages(self, count=1, block=True, timeout=10): """ Fetch the specified number of messages Keyword Arguments: count: Indicates the maximum number of messages to be fetched block: If True, the API will block till all messages are fetched. If block...
python
def get_messages(self, count=1, block=True, timeout=10): """ Fetch the specified number of messages Keyword Arguments: count: Indicates the maximum number of messages to be fetched block: If True, the API will block till all messages are fetched. If block...
[ "def", "get_messages", "(", "self", ",", "count", "=", "1", ",", "block", "=", "True", ",", "timeout", "=", "10", ")", ":", "messages", "=", "[", "]", "# Give a size hint to the consumers. Each consumer process will fetch", "# a maximum of \"count\" messages. This will ...
Fetch the specified number of messages Keyword Arguments: count: Indicates the maximum number of messages to be fetched block: If True, the API will block till all messages are fetched. If block is a positive integer the API will block until that many mes...
[ "Fetch", "the", "specified", "number", "of", "messages" ]
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/consumer/multiprocess.py#L238-L295
train
Fetch the specified number of messages from the queue and return them as a list of Message objects.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
dpkp/kafka-python
kafka/context.py
OffsetCommitContext.mark
def mark(self, partition, offset): """ Set the high-water mark in the current context. In order to know the current partition, it is helpful to initialize the consumer to provide partition info via: .. code:: python consumer.provide_partition_info() """ ...
python
def mark(self, partition, offset): """ Set the high-water mark in the current context. In order to know the current partition, it is helpful to initialize the consumer to provide partition info via: .. code:: python consumer.provide_partition_info() """ ...
[ "def", "mark", "(", "self", ",", "partition", ",", "offset", ")", ":", "max_offset", "=", "max", "(", "offset", "+", "1", ",", "self", ".", "high_water_mark", ".", "get", "(", "partition", ",", "0", ")", ")", "self", ".", "logger", ".", "debug", "(...
Set the high-water mark in the current context. In order to know the current partition, it is helpful to initialize the consumer to provide partition info via: .. code:: python consumer.provide_partition_info()
[ "Set", "the", "high", "-", "water", "mark", "in", "the", "current", "context", "." ]
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/context.py#L58-L75
train
Set the high - water mark for the given partition.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
dpkp/kafka-python
kafka/context.py
OffsetCommitContext.commit
def commit(self): """ Commit this context's offsets: - If the high-water mark has moved, commit up to and position the consumer at the high-water mark. - Otherwise, reset to the consumer to the initial offsets. """ if self.high_water_mark: sel...
python
def commit(self): """ Commit this context's offsets: - If the high-water mark has moved, commit up to and position the consumer at the high-water mark. - Otherwise, reset to the consumer to the initial offsets. """ if self.high_water_mark: sel...
[ "def", "commit", "(", "self", ")", ":", "if", "self", ".", "high_water_mark", ":", "self", ".", "logger", ".", "info", "(", "\"Committing offsets: %s\"", ",", "self", ".", "high_water_mark", ")", "self", ".", "commit_partition_offsets", "(", "self", ".", "hi...
Commit this context's offsets: - If the high-water mark has moved, commit up to and position the consumer at the high-water mark. - Otherwise, reset to the consumer to the initial offsets.
[ "Commit", "this", "context", "s", "offsets", ":" ]
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/context.py#L114-L127
train
Commit the offsets of this context.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
dpkp/kafka-python
kafka/context.py
OffsetCommitContext.rollback
def rollback(self): """ Rollback this context: - Position the consumer at the initial offsets. """ self.logger.info("Rolling back context: %s", self.initial_offsets) self.update_consumer_offsets(self.initial_offsets)
python
def rollback(self): """ Rollback this context: - Position the consumer at the initial offsets. """ self.logger.info("Rolling back context: %s", self.initial_offsets) self.update_consumer_offsets(self.initial_offsets)
[ "def", "rollback", "(", "self", ")", ":", "self", ".", "logger", ".", "info", "(", "\"Rolling back context: %s\"", ",", "self", ".", "initial_offsets", ")", "self", ".", "update_consumer_offsets", "(", "self", ".", "initial_offsets", ")" ]
Rollback this context: - Position the consumer at the initial offsets.
[ "Rollback", "this", "context", ":" ]
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/context.py#L129-L136
train
Roll back the consumer context.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
dpkp/kafka-python
kafka/context.py
OffsetCommitContext.commit_partition_offsets
def commit_partition_offsets(self, partition_offsets): """ Commit explicit partition/offset pairs. """ self.logger.debug("Committing partition offsets: %s", partition_offsets) commit_requests = [ OffsetCommitRequestPayload(self.consumer.topic, partition, offset, None...
python
def commit_partition_offsets(self, partition_offsets): """ Commit explicit partition/offset pairs. """ self.logger.debug("Committing partition offsets: %s", partition_offsets) commit_requests = [ OffsetCommitRequestPayload(self.consumer.topic, partition, offset, None...
[ "def", "commit_partition_offsets", "(", "self", ",", "partition_offsets", ")", ":", "self", ".", "logger", ".", "debug", "(", "\"Committing partition offsets: %s\"", ",", "partition_offsets", ")", "commit_requests", "=", "[", "OffsetCommitRequestPayload", "(", "self", ...
Commit explicit partition/offset pairs.
[ "Commit", "explicit", "partition", "/", "offset", "pairs", "." ]
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/context.py#L138-L153
train
Commit explicit partition and offset pairs.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
dpkp/kafka-python
kafka/context.py
OffsetCommitContext.update_consumer_offsets
def update_consumer_offsets(self, partition_offsets): """ Update consumer offsets to explicit positions. """ self.logger.debug("Updating consumer offsets to: %s", partition_offsets) for partition, offset in partition_offsets.items(): self.consumer.offsets[partition] ...
python
def update_consumer_offsets(self, partition_offsets): """ Update consumer offsets to explicit positions. """ self.logger.debug("Updating consumer offsets to: %s", partition_offsets) for partition, offset in partition_offsets.items(): self.consumer.offsets[partition] ...
[ "def", "update_consumer_offsets", "(", "self", ",", "partition_offsets", ")", ":", "self", ".", "logger", ".", "debug", "(", "\"Updating consumer offsets to: %s\"", ",", "partition_offsets", ")", "for", "partition", ",", "offset", "in", "partition_offsets", ".", "it...
Update consumer offsets to explicit positions.
[ "Update", "consumer", "offsets", "to", "explicit", "positions", "." ]
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/context.py#L155-L167
train
Update consumer offsets to explicit positions.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
dpkp/kafka-python
kafka/coordinator/base.py
BaseCoordinator.coordinator
def coordinator(self): """Get the current coordinator Returns: the current coordinator id or None if it is unknown """ if self.coordinator_id is None: return None elif self._client.is_disconnected(self.coordinator_id): self.coordinator_dead('Node Disconne...
python
def coordinator(self): """Get the current coordinator Returns: the current coordinator id or None if it is unknown """ if self.coordinator_id is None: return None elif self._client.is_disconnected(self.coordinator_id): self.coordinator_dead('Node Disconne...
[ "def", "coordinator", "(", "self", ")", ":", "if", "self", ".", "coordinator_id", "is", "None", ":", "return", "None", "elif", "self", ".", "_client", ".", "is_disconnected", "(", "self", ".", "coordinator_id", ")", ":", "self", ".", "coordinator_dead", "(...
Get the current coordinator Returns: the current coordinator id or None if it is unknown
[ "Get", "the", "current", "coordinator" ]
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/coordinator/base.py#L229-L240
train
Get the current coordinator id
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
dpkp/kafka-python
kafka/coordinator/base.py
BaseCoordinator.ensure_coordinator_ready
def ensure_coordinator_ready(self): """Block until the coordinator for this group is known (and we have an active connection -- java client uses unsent queue). """ with self._client._lock, self._lock: while self.coordinator_unknown(): # Prior to 0.8.2 there w...
python
def ensure_coordinator_ready(self): """Block until the coordinator for this group is known (and we have an active connection -- java client uses unsent queue). """ with self._client._lock, self._lock: while self.coordinator_unknown(): # Prior to 0.8.2 there w...
[ "def", "ensure_coordinator_ready", "(", "self", ")", ":", "with", "self", ".", "_client", ".", "_lock", ",", "self", ".", "_lock", ":", "while", "self", ".", "coordinator_unknown", "(", ")", ":", "# Prior to 0.8.2 there was no group coordinator", "# so we will just ...
Block until the coordinator for this group is known (and we have an active connection -- java client uses unsent queue).
[ "Block", "until", "the", "coordinator", "for", "this", "group", "is", "known", "(", "and", "we", "have", "an", "active", "connection", "--", "java", "client", "uses", "unsent", "queue", ")", "." ]
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/coordinator/base.py#L242-L270
train
Block until the coordinator is ready for this group.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
dpkp/kafka-python
kafka/coordinator/base.py
BaseCoordinator.poll_heartbeat
def poll_heartbeat(self): """ Check the status of the heartbeat thread (if it is active) and indicate the liveness of the client. This must be called periodically after joining with :meth:`.ensure_active_group` to ensure that the member stays in the group. If an interval of time ...
python
def poll_heartbeat(self): """ Check the status of the heartbeat thread (if it is active) and indicate the liveness of the client. This must be called periodically after joining with :meth:`.ensure_active_group` to ensure that the member stays in the group. If an interval of time ...
[ "def", "poll_heartbeat", "(", "self", ")", ":", "with", "self", ".", "_lock", ":", "if", "self", ".", "_heartbeat_thread", "is", "not", "None", ":", "if", "self", ".", "_heartbeat_thread", ".", "failed", ":", "# set the heartbeat thread to None and raise an except...
Check the status of the heartbeat thread (if it is active) and indicate the liveness of the client. This must be called periodically after joining with :meth:`.ensure_active_group` to ensure that the member stays in the group. If an interval of time longer than the provided rebalance tim...
[ "Check", "the", "status", "of", "the", "heartbeat", "thread", "(", "if", "it", "is", "active", ")", "and", "indicate", "the", "liveness", "of", "the", "client", ".", "This", "must", "be", "called", "periodically", "after", "joining", "with", ":", "meth", ...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/coordinator/base.py#L297-L321
train
Poll the heartbeat thread for the given entry.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
dpkp/kafka-python
kafka/coordinator/base.py
BaseCoordinator.ensure_active_group
def ensure_active_group(self): """Ensure that the group is active (i.e. joined and synced)""" with self._client._lock, self._lock: if self._heartbeat_thread is None: self._start_heartbeat_thread() while self.need_rejoin() or self._rejoin_incomplete(): ...
python
def ensure_active_group(self): """Ensure that the group is active (i.e. joined and synced)""" with self._client._lock, self._lock: if self._heartbeat_thread is None: self._start_heartbeat_thread() while self.need_rejoin() or self._rejoin_incomplete(): ...
[ "def", "ensure_active_group", "(", "self", ")", ":", "with", "self", ".", "_client", ".", "_lock", ",", "self", ".", "_lock", ":", "if", "self", ".", "_heartbeat_thread", "is", "None", ":", "self", ".", "_start_heartbeat_thread", "(", ")", "while", "self",...
Ensure that the group is active (i.e. joined and synced)
[ "Ensure", "that", "the", "group", "is", "active", "(", "i", ".", "e", ".", "joined", "and", "synced", ")" ]
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/coordinator/base.py#L343-L423
train
Ensure that the group is active.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
dpkp/kafka-python
kafka/coordinator/base.py
BaseCoordinator._send_join_group_request
def _send_join_group_request(self): """Join the group and return the assignment for the next generation. This function handles both JoinGroup and SyncGroup, delegating to :meth:`._perform_assignment` if elected leader by the coordinator. Returns: Future: resolves to the enc...
python
def _send_join_group_request(self): """Join the group and return the assignment for the next generation. This function handles both JoinGroup and SyncGroup, delegating to :meth:`._perform_assignment` if elected leader by the coordinator. Returns: Future: resolves to the enc...
[ "def", "_send_join_group_request", "(", "self", ")", ":", "if", "self", ".", "coordinator_unknown", "(", ")", ":", "e", "=", "Errors", ".", "GroupCoordinatorNotAvailableError", "(", "self", ".", "coordinator_id", ")", "return", "Future", "(", ")", ".", "failur...
Join the group and return the assignment for the next generation. This function handles both JoinGroup and SyncGroup, delegating to :meth:`._perform_assignment` if elected leader by the coordinator. Returns: Future: resolves to the encoded-bytes assignment returned from the ...
[ "Join", "the", "group", "and", "return", "the", "assignment", "for", "the", "next", "generation", "." ]
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/coordinator/base.py#L428-L485
train
Sends a JoinGroupRequest request to the coordinator.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
dpkp/kafka-python
kafka/coordinator/base.py
BaseCoordinator._on_join_leader
def _on_join_leader(self, response): """ Perform leader synchronization and send back the assignment for the group via SyncGroupRequest Arguments: response (JoinResponse): broker response to parse Returns: Future: resolves to member assignment encoded-by...
python
def _on_join_leader(self, response): """ Perform leader synchronization and send back the assignment for the group via SyncGroupRequest Arguments: response (JoinResponse): broker response to parse Returns: Future: resolves to member assignment encoded-by...
[ "def", "_on_join_leader", "(", "self", ",", "response", ")", ":", "try", ":", "group_assignment", "=", "self", ".", "_perform_assignment", "(", "response", ".", "leader_id", ",", "response", ".", "group_protocol", ",", "response", ".", "members", ")", "except"...
Perform leader synchronization and send back the assignment for the group via SyncGroupRequest Arguments: response (JoinResponse): broker response to parse Returns: Future: resolves to member assignment encoded-bytes
[ "Perform", "leader", "synchronization", "and", "send", "back", "the", "assignment", "for", "the", "group", "via", "SyncGroupRequest" ]
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/coordinator/base.py#L569-L598
train
Perform leader synchronization and send back the assignment for the group via SyncGroupRequest
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
dpkp/kafka-python
kafka/coordinator/base.py
BaseCoordinator._send_group_coordinator_request
def _send_group_coordinator_request(self): """Discover the current coordinator for the group. Returns: Future: resolves to the node id of the coordinator """ node_id = self._client.least_loaded_node() if node_id is None: return Future().failure(Errors.NoB...
python
def _send_group_coordinator_request(self): """Discover the current coordinator for the group. Returns: Future: resolves to the node id of the coordinator """ node_id = self._client.least_loaded_node() if node_id is None: return Future().failure(Errors.NoB...
[ "def", "_send_group_coordinator_request", "(", "self", ")", ":", "node_id", "=", "self", ".", "_client", ".", "least_loaded_node", "(", ")", "if", "node_id", "is", "None", ":", "return", "Future", "(", ")", ".", "failure", "(", "Errors", ".", "NoBrokersAvail...
Discover the current coordinator for the group. Returns: Future: resolves to the node id of the coordinator
[ "Discover", "the", "current", "coordinator", "for", "the", "group", "." ]
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/coordinator/base.py#L650-L671
train
Send a request to the broker to discover the current coordinator for the group.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
dpkp/kafka-python
kafka/coordinator/base.py
BaseCoordinator.coordinator_dead
def coordinator_dead(self, error): """Mark the current coordinator as dead.""" if self.coordinator_id is not None: log.warning("Marking the coordinator dead (node %s) for group %s: %s.", self.coordinator_id, self.group_id, error) self.coordinator_id = None
python
def coordinator_dead(self, error): """Mark the current coordinator as dead.""" if self.coordinator_id is not None: log.warning("Marking the coordinator dead (node %s) for group %s: %s.", self.coordinator_id, self.group_id, error) self.coordinator_id = None
[ "def", "coordinator_dead", "(", "self", ",", "error", ")", ":", "if", "self", ".", "coordinator_id", "is", "not", "None", ":", "log", ".", "warning", "(", "\"Marking the coordinator dead (node %s) for group %s: %s.\"", ",", "self", ".", "coordinator_id", ",", "sel...
Mark the current coordinator as dead.
[ "Mark", "the", "current", "coordinator", "as", "dead", "." ]
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/coordinator/base.py#L706-L711
train
Mark the current coordinator as dead.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
dpkp/kafka-python
kafka/coordinator/base.py
BaseCoordinator.generation
def generation(self): """Get the current generation state if the group is stable. Returns: the current generation or None if the group is unjoined/rebalancing """ with self._lock: if self.state is not MemberState.STABLE: return None return self._g...
python
def generation(self): """Get the current generation state if the group is stable. Returns: the current generation or None if the group is unjoined/rebalancing """ with self._lock: if self.state is not MemberState.STABLE: return None return self._g...
[ "def", "generation", "(", "self", ")", ":", "with", "self", ".", "_lock", ":", "if", "self", ".", "state", "is", "not", "MemberState", ".", "STABLE", ":", "return", "None", "return", "self", ".", "_generation" ]
Get the current generation state if the group is stable. Returns: the current generation or None if the group is unjoined/rebalancing
[ "Get", "the", "current", "generation", "state", "if", "the", "group", "is", "stable", "." ]
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/coordinator/base.py#L713-L721
train
Get the current generation state if the group is stable.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
dpkp/kafka-python
kafka/coordinator/base.py
BaseCoordinator.reset_generation
def reset_generation(self): """Reset the generation and memberId because we have fallen out of the group.""" with self._lock: self._generation = Generation.NO_GENERATION self.rejoin_needed = True self.state = MemberState.UNJOINED
python
def reset_generation(self): """Reset the generation and memberId because we have fallen out of the group.""" with self._lock: self._generation = Generation.NO_GENERATION self.rejoin_needed = True self.state = MemberState.UNJOINED
[ "def", "reset_generation", "(", "self", ")", ":", "with", "self", ".", "_lock", ":", "self", ".", "_generation", "=", "Generation", ".", "NO_GENERATION", "self", ".", "rejoin_needed", "=", "True", "self", ".", "state", "=", "MemberState", ".", "UNJOINED" ]
Reset the generation and memberId because we have fallen out of the group.
[ "Reset", "the", "generation", "and", "memberId", "because", "we", "have", "fallen", "out", "of", "the", "group", "." ]
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/coordinator/base.py#L723-L728
train
Reset the generation and memberId because we have fallen out of the group.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...