Search is not available for this dataset
identifier stringlengths 1 155 | parameters stringlengths 2 6.09k | docstring stringlengths 11 63.4k | docstring_summary stringlengths 0 63.4k | function stringlengths 29 99.8k | function_tokens list | start_point list | end_point list | language stringclasses 1
value | docstring_language stringlengths 2 7 | docstring_language_predictions stringlengths 18 23 | is_langid_reliable stringclasses 2
values |
|---|---|---|---|---|---|---|---|---|---|---|---|
FixedDialogTeacher.reset | (self) |
Reset the dialog to the start of the epoch, and reset all metrics.
|
Reset the dialog to the start of the epoch, and reset all metrics.
| def reset(self):
"""
Reset the dialog to the start of the epoch, and reset all metrics.
"""
super().reset()
self.metrics.clear()
self.lastY = None
self.last_act = None
self._episode_done = True
self.epochDone = False
self.data_queue = queue... | [
"def",
"reset",
"(",
"self",
")",
":",
"super",
"(",
")",
".",
"reset",
"(",
")",
"self",
".",
"metrics",
".",
"clear",
"(",
")",
"self",
".",
"lastY",
"=",
"None",
"self",
".",
"last_act",
"=",
"None",
"self",
".",
"_episode_done",
"=",
"True",
... | [
287,
4
] | [
301,
33
] | python | en | ['en', 'error', 'th'] | False |
FixedDialogTeacher.submit_load_request | (self) |
Submit a load request.
An agent should implement this method to submit requests to the data
loader. At the end of this method, the agent should call
``self.data_loader.request_load()`` with the appropriate args.
By default, this method does nothing.
|
Submit a load request. | def submit_load_request(self):
"""
Submit a load request.
An agent should implement this method to submit requests to the data
loader. At the end of this method, the agent should call
``self.data_loader.request_load()`` with the appropriate args.
By default, this method... | [
"def",
"submit_load_request",
"(",
"self",
")",
":",
"# TODO: mark as abstract",
"pass"
] | [
303,
4
] | [
314,
12
] | python | en | ['en', 'error', 'th'] | False |
FixedDialogTeacher.receive_data | (self, future) |
Receive data from the data loader.
:param future: result from the load request.
|
Receive data from the data loader. | def receive_data(self, future):
"""
Receive data from the data loader.
:param future: result from the load request.
"""
data = future.result()
self.data_queue.put(data) | [
"def",
"receive_data",
"(",
"self",
",",
"future",
")",
":",
"data",
"=",
"future",
".",
"result",
"(",
")",
"self",
".",
"data_queue",
".",
"put",
"(",
"data",
")"
] | [
316,
4
] | [
323,
33
] | python | en | ['en', 'error', 'th'] | False |
FixedDialogTeacher.share | (self) |
Share the data and dataloader.
|
Share the data and dataloader.
| def share(self):
"""
Share the data and dataloader.
"""
shared = super().share()
if hasattr(self, 'examples'):
shared['examples'] = self.examples
if hasattr(self, 'data_loader'):
shared['data_loader'] = self.data_loader
shared['index'] =... | [
"def",
"share",
"(",
"self",
")",
":",
"shared",
"=",
"super",
"(",
")",
".",
"share",
"(",
")",
"if",
"hasattr",
"(",
"self",
",",
"'examples'",
")",
":",
"shared",
"[",
"'examples'",
"]",
"=",
"self",
".",
"examples",
"if",
"hasattr",
"(",
"self"... | [
325,
4
] | [
339,
21
] | python | en | ['en', 'error', 'th'] | False |
FixedDialogTeacher.next_episode_idx | (self, num_eps=None, loop=None) |
Return the next episode index.
:param num_eps:
default None uses ``num_episodes`` value.
:param loop:
default None loops during training but not evaluation.
|
Return the next episode index. | def next_episode_idx(self, num_eps=None, loop=None):
"""
Return the next episode index.
:param num_eps:
default None uses ``num_episodes`` value.
:param loop:
default None loops during training but not evaluation.
"""
if num_eps is None:
... | [
"def",
"next_episode_idx",
"(",
"self",
",",
"num_eps",
"=",
"None",
",",
"loop",
"=",
"None",
")",
":",
"if",
"num_eps",
"is",
"None",
":",
"num_eps",
"=",
"self",
".",
"num_episodes",
"(",
")",
"if",
"loop",
"is",
"None",
":",
"loop",
"=",
"self",
... | [
341,
4
] | [
362,
22
] | python | en | ['en', 'error', 'th'] | False |
FixedDialogTeacher.next_example | (self) |
Return the next example.
If there are multiple examples in the same episode, returns the next one in that
episode. If that episode is over, gets a new episode index and returns the first
example of that episode.
|
Return the next example. | def next_example(self):
"""
Return the next example.
If there are multiple examples in the same episode, returns the next one in that
episode. If that episode is over, gets a new episode index and returns the first
example of that episode.
"""
if self._episode_do... | [
"def",
"next_example",
"(",
"self",
")",
":",
"if",
"self",
".",
"_episode_done",
":",
"self",
".",
"episode_idx",
"=",
"self",
".",
"next_episode_idx",
"(",
")",
"self",
".",
"entry_idx",
"=",
"0",
"else",
":",
"self",
".",
"entry_idx",
"+=",
"1",
"if... | [
364,
4
] | [
393,
29
] | python | en | ['en', 'error', 'th'] | False |
FixedDialogTeacher.next_batch | (self) |
Return the next batch of examples.
|
Return the next batch of examples.
| def next_batch(self):
"""
Return the next batch of examples.
"""
# get next batch
with self._lock():
self.index.value += 1
if self.training:
self.index.value %= len(self.batches)
batch_idx = self.index.value
if batc... | [
"def",
"next_batch",
"(",
"self",
")",
":",
"# get next batch",
"with",
"self",
".",
"_lock",
"(",
")",
":",
"self",
".",
"index",
".",
"value",
"+=",
"1",
"if",
"self",
".",
"training",
":",
"self",
".",
"index",
".",
"value",
"%=",
"len",
"(",
"s... | [
395,
4
] | [
416,
38
] | python | en | ['en', 'error', 'th'] | False |
FixedDialogTeacher.num_episodes | (self) |
Get the number of episodes in this dataset.
|
Get the number of episodes in this dataset.
| def num_episodes(self) -> int:
"""
Get the number of episodes in this dataset.
"""
raise RuntimeError('"num_episodes" must be overriden by children.') | [
"def",
"num_episodes",
"(",
"self",
")",
"->",
"int",
":",
"raise",
"RuntimeError",
"(",
"'\"num_episodes\" must be overriden by children.'",
")"
] | [
418,
4
] | [
422,
75
] | python | en | ['en', 'error', 'th'] | False |
FixedDialogTeacher.num_examples | (self) |
Get the total number of examples in this dataset.
|
Get the total number of examples in this dataset.
| def num_examples(self) -> int:
"""
Get the total number of examples in this dataset.
"""
raise RuntimeError('"num_examples" must be overriden by children.') | [
"def",
"num_examples",
"(",
"self",
")",
"->",
"int",
":",
"raise",
"RuntimeError",
"(",
"'\"num_examples\" must be overriden by children.'",
")"
] | [
424,
4
] | [
428,
75
] | python | en | ['en', 'error', 'th'] | False |
FixedDialogTeacher.get | (self, episode_idx, entry_idx=0) |
Get the specified episode and the specified entry in that episode.
Children must override this method in order to inherit the
`next_example` method.
:param episode_idx:
which episode to return examples from
:param entry_idx:
which example to return from... |
Get the specified episode and the specified entry in that episode. | def get(self, episode_idx, entry_idx=0):
"""
Get the specified episode and the specified entry in that episode.
Children must override this method in order to inherit the
`next_example` method.
:param episode_idx:
which episode to return examples from
:param... | [
"def",
"get",
"(",
"self",
",",
"episode_idx",
",",
"entry_idx",
"=",
"0",
")",
":",
"# TODO: mark as abstract, get rid of runtime error.",
"raise",
"RuntimeError",
"(",
"'\"Get\" method must be overriden by children.'",
")"
] | [
430,
4
] | [
444,
73
] | python | en | ['en', 'error', 'th'] | False |
FixedDialogTeacher.observe | (self, observation) |
Process observation for metrics.
|
Process observation for metrics.
| def observe(self, observation):
"""
Process observation for metrics.
"""
self.metrics.clear_recent()
if hasattr(self, 'lastY') and self.lastY is not None:
self.metrics.evaluate_response(observation, self.lastY)
self.custom_evaluation(self.last_act, self.la... | [
"def",
"observe",
"(",
"self",
",",
"observation",
")",
":",
"self",
".",
"metrics",
".",
"clear_recent",
"(",
")",
"if",
"hasattr",
"(",
"self",
",",
"'lastY'",
")",
"and",
"self",
".",
"lastY",
"is",
"not",
"None",
":",
"self",
".",
"metrics",
".",... | [
446,
4
] | [
464,
26
] | python | en | ['en', 'error', 'th'] | False |
FixedDialogTeacher.custom_evaluation | (
self,
teacher_action: Message,
labels: Optional[Tuple[str]],
model_response: Message,
) |
A method designated for hooking custom evaluations into teachers.
Generally, a user will want to use `self.metrics.add` to record any
specialized metrics that only make sense for this one dataset.
:param teacher_action:
The message last sent from this teacher.
:par... |
A method designated for hooking custom evaluations into teachers. | def custom_evaluation(
self,
teacher_action: Message,
labels: Optional[Tuple[str]],
model_response: Message,
) -> None:
"""
A method designated for hooking custom evaluations into teachers.
Generally, a user will want to use `self.metrics.add` to record any
... | [
"def",
"custom_evaluation",
"(",
"self",
",",
"teacher_action",
":",
"Message",
",",
"labels",
":",
"Optional",
"[",
"Tuple",
"[",
"str",
"]",
"]",
",",
"model_response",
":",
"Message",
",",
")",
"->",
"None",
":",
"pass"
] | [
466,
4
] | [
486,
12
] | python | en | ['en', 'error', 'th'] | False |
FixedDialogTeacher.act | (self) |
Send new dialog message.
|
Send new dialog message.
| def act(self):
"""
Send new dialog message.
"""
orig_action = self.get_orig_action()
processed_action = self.process_action(orig_action)
return processed_action | [
"def",
"act",
"(",
"self",
")",
":",
"orig_action",
"=",
"self",
".",
"get_orig_action",
"(",
")",
"processed_action",
"=",
"self",
".",
"process_action",
"(",
"orig_action",
")",
"return",
"processed_action"
] | [
488,
4
] | [
494,
31
] | python | en | ['en', 'error', 'th'] | False |
FixedDialogTeacher.get_orig_action | (self) |
Get the unprocessed action and reset if needed.
This function will return the raw action from `self.next_example()`, before the
`self.last_act` and `self.lastY` attributes have been defined based on this
action for metrics or custom evaluations. This is so that wrapper teachers can
... |
Get the unprocessed action and reset if needed. | def get_orig_action(self) -> Message:
"""
Get the unprocessed action and reset if needed.
This function will return the raw action from `self.next_example()`, before the
`self.last_act` and `self.lastY` attributes have been defined based on this
action for metrics or custom eval... | [
"def",
"get_orig_action",
"(",
"self",
")",
"->",
"Message",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'epochDone'",
")",
":",
"# reset if haven't yet",
"self",
".",
"reset",
"(",
")",
"# get next example, action is episode_done dict if already out of exs",
"act... | [
496,
4
] | [
517,
21
] | python | en | ['en', 'error', 'th'] | False |
FixedDialogTeacher.process_action | (self, action: Message) |
Remember the raw action and prepare its fields for passing out of the teacher.
|
Remember the raw action and prepare its fields for passing out of the teacher.
| def process_action(self, action: Message) -> Message:
"""
Remember the raw action and prepare its fields for passing out of the teacher.
"""
action.force_set('id', self.getID())
# remember correct answer if available
self.last_act = action
self.lastY = action.get... | [
"def",
"process_action",
"(",
"self",
",",
"action",
":",
"Message",
")",
"->",
"Message",
":",
"action",
".",
"force_set",
"(",
"'id'",
",",
"self",
".",
"getID",
"(",
")",
")",
"# remember correct answer if available",
"self",
".",
"last_act",
"=",
"action... | [
519,
4
] | [
536,
21
] | python | en | ['en', 'error', 'th'] | False |
DialogTeacher.setup_data | (self, datafile: str) |
The core method which the user should override.
Yields the data, one message at a time, as well as markers indicating
new episodes.
:param str datafile:
If the initializer set a 'datafile' field within the initalization,
this will be provided here. Otherwise, d... |
The core method which the user should override. | def setup_data(self, datafile: str):
"""
The core method which the user should override.
Yields the data, one message at a time, as well as markers indicating
new episodes.
:param str datafile:
If the initializer set a 'datafile' field within the initalization,
... | [
"def",
"setup_data",
"(",
"self",
",",
"datafile",
":",
"str",
")",
":",
"pass"
] | [
596,
4
] | [
613,
12
] | python | en | ['en', 'error', 'th'] | False |
DialogTeacher.reset | (self) |
Reset the dialog to the start of the epoch, reset all metrics.
|
Reset the dialog to the start of the epoch, reset all metrics.
| def reset(self):
"""
Reset the dialog to the start of the epoch, reset all metrics.
"""
super().reset()
if self.stream:
self.data.reset()
self.epochDone = False | [
"def",
"reset",
"(",
"self",
")",
":",
"super",
"(",
")",
".",
"reset",
"(",
")",
"if",
"self",
".",
"stream",
":",
"self",
".",
"data",
".",
"reset",
"(",
")",
"self",
".",
"epochDone",
"=",
"False"
] | [
615,
4
] | [
622,
34
] | python | en | ['en', 'error', 'th'] | False |
DialogTeacher.share | (self) |
Share the data.
|
Share the data.
| def share(self):
"""
Share the data.
"""
shared = super().share()
if hasattr(self, 'data'):
shared['data'] = self.data.share()
return shared | [
"def",
"share",
"(",
"self",
")",
":",
"shared",
"=",
"super",
"(",
")",
".",
"share",
"(",
")",
"if",
"hasattr",
"(",
"self",
",",
"'data'",
")",
":",
"shared",
"[",
"'data'",
"]",
"=",
"self",
".",
"data",
".",
"share",
"(",
")",
"return",
"s... | [
624,
4
] | [
631,
21
] | python | en | ['en', 'error', 'th'] | False |
DialogTeacher.label_candidates | (self) |
Provide consistent label candidates for all examples.
Default implementation returns ``None`` always, but this may be overriden to
provide candidates in all areas. See ``FbDialogueTeacher``.
|
Provide consistent label candidates for all examples. | def label_candidates(self):
"""
Provide consistent label candidates for all examples.
Default implementation returns ``None`` always, but this may be overriden to
provide candidates in all areas. See ``FbDialogueTeacher``.
"""
# TODO DEPRECATIONDAY: FbiDialogueTeacher is... | [
"def",
"label_candidates",
"(",
"self",
")",
":",
"# TODO DEPRECATIONDAY: FbiDialogueTeacher is being deprecated, should we",
"# remove this?",
"# TODO: mark as optionally abstract?",
"return",
"None"
] | [
633,
4
] | [
644,
19
] | python | en | ['en', 'error', 'th'] | False |
DialogTeacher.num_episodes | (self) |
Return the number of episodes in the data.
|
Return the number of episodes in the data.
| def num_episodes(self) -> int:
"""
Return the number of episodes in the data.
"""
try:
return self.data.num_episodes()
except AttributeError:
return super().num_episodes() | [
"def",
"num_episodes",
"(",
"self",
")",
"->",
"int",
":",
"try",
":",
"return",
"self",
".",
"data",
".",
"num_episodes",
"(",
")",
"except",
"AttributeError",
":",
"return",
"super",
"(",
")",
".",
"num_episodes",
"(",
")"
] | [
646,
4
] | [
653,
41
] | python | en | ['en', 'error', 'th'] | False |
DialogTeacher.num_examples | (self) |
Return the number of examples in the data.
|
Return the number of examples in the data.
| def num_examples(self) -> int:
"""
Return the number of examples in the data.
"""
if hasattr(self, '_num_examples_cache'):
return self._num_examples_cache
try:
self._num_examples_cache: int = self.data.num_examples()
except AttributeError:
... | [
"def",
"num_examples",
"(",
"self",
")",
"->",
"int",
":",
"if",
"hasattr",
"(",
"self",
",",
"'_num_examples_cache'",
")",
":",
"return",
"self",
".",
"_num_examples_cache",
"try",
":",
"self",
".",
"_num_examples_cache",
":",
"int",
"=",
"self",
".",
"da... | [
655,
4
] | [
665,
39
] | python | en | ['en', 'error', 'th'] | False |
DialogTeacher.get | (self, episode_idx, entry_idx=0) |
Get a specific example.
|
Get a specific example.
| def get(self, episode_idx, entry_idx=0):
"""
Get a specific example.
"""
return self.data.get(episode_idx, entry_idx)[0] | [
"def",
"get",
"(",
"self",
",",
"episode_idx",
",",
"entry_idx",
"=",
"0",
")",
":",
"return",
"self",
".",
"data",
".",
"get",
"(",
"episode_idx",
",",
"entry_idx",
")",
"[",
"0",
"]"
] | [
667,
4
] | [
671,
55
] | python | en | ['en', 'error', 'th'] | False |
DialogTeacher.next_example | (self) |
Get the next example.
|
Get the next example.
| def next_example(self):
"""
Get the next example.
"""
if self.stream:
action, epoch_done = self.data.get()
else:
action, epoch_done = super().next_example()
return action, epoch_done | [
"def",
"next_example",
"(",
"self",
")",
":",
"if",
"self",
".",
"stream",
":",
"action",
",",
"epoch_done",
"=",
"self",
".",
"data",
".",
"get",
"(",
")",
"else",
":",
"action",
",",
"epoch_done",
"=",
"super",
"(",
")",
".",
"next_example",
"(",
... | [
673,
4
] | [
681,
33
] | python | en | ['en', 'error', 'th'] | False |
DialogData.share | (self) |
Share the data.
|
Share the data.
| def share(self):
"""
Share the data.
"""
shared = {
'data': self.data,
'cands': self.cands,
'image_loader': self.image_loader,
}
return shared | [
"def",
"share",
"(",
"self",
")",
":",
"shared",
"=",
"{",
"'data'",
":",
"self",
".",
"data",
",",
"'cands'",
":",
"self",
".",
"cands",
",",
"'image_loader'",
":",
"self",
".",
"image_loader",
",",
"}",
"return",
"shared"
] | [
754,
4
] | [
763,
21
] | python | en | ['en', 'error', 'th'] | False |
DialogData._read_episode | (self, data_loader) |
Read one episode at a time from the provided iterable over entries.
:param data_loader:
an iterable which returns tuples in the format described in the
class docstring.
|
Read one episode at a time from the provided iterable over entries. | def _read_episode(self, data_loader):
"""
Read one episode at a time from the provided iterable over entries.
:param data_loader:
an iterable which returns tuples in the format described in the
class docstring.
"""
episode = []
for entry, new in ... | [
"def",
"_read_episode",
"(",
"self",
",",
"data_loader",
")",
":",
"episode",
"=",
"[",
"]",
"for",
"entry",
",",
"new",
"in",
"data_loader",
":",
"if",
"new",
"and",
"len",
"(",
"episode",
")",
">",
"0",
":",
"yield",
"tuple",
"(",
"episode",
")",
... | [
765,
4
] | [
783,
32
] | python | en | ['en', 'error', 'th'] | False |
DialogData._load | (self, data_loader, datafile) |
Load up data from an iterable over tuples described in the class docs.
:param iter data_loader:
an iterator which returns tuples in the format described in the
class docstring.
:param str datafile:
|
Load up data from an iterable over tuples described in the class docs. | def _load(self, data_loader, datafile):
"""
Load up data from an iterable over tuples described in the class docs.
:param iter data_loader:
an iterator which returns tuples in the format described in the
class docstring.
:param str datafile:
"""
f... | [
"def",
"_load",
"(",
"self",
",",
"data_loader",
",",
"datafile",
")",
":",
"for",
"i",
",",
"episode",
"in",
"enumerate",
"(",
"self",
".",
"_read_episode",
"(",
"data_loader",
"(",
"datafile",
")",
")",
")",
":",
"if",
"not",
"self",
".",
"is_distrib... | [
785,
4
] | [
796,
41
] | python | en | ['en', 'error', 'th'] | False |
DialogData.num_episodes | (self) |
Return number of episodes in the dataset.
|
Return number of episodes in the dataset.
| def num_episodes(self):
"""
Return number of episodes in the dataset.
"""
return len(self.data) | [
"def",
"num_episodes",
"(",
"self",
")",
":",
"return",
"len",
"(",
"self",
".",
"data",
")"
] | [
798,
4
] | [
802,
29
] | python | en | ['en', 'error', 'th'] | False |
DialogData.num_examples | (self) |
Return total number of entries available.
Each episode has at least one entry, but might have many more.
|
Return total number of entries available. | def num_examples(self):
"""
Return total number of entries available.
Each episode has at least one entry, but might have many more.
"""
if hasattr(self, '_num_examples_cache'):
return self._num_examples_cache
self._num_examples_cache = sum(len(episode) for e... | [
"def",
"num_examples",
"(",
"self",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"'_num_examples_cache'",
")",
":",
"return",
"self",
".",
"_num_examples_cache",
"self",
".",
"_num_examples_cache",
"=",
"sum",
"(",
"len",
"(",
"episode",
")",
"for",
"episode... | [
804,
4
] | [
813,
39
] | python | en | ['en', 'error', 'th'] | False |
DialogData.get | (self, episode_idx, entry_idx=0) |
Get the specified episode and the specified entry in that episode.
:param episode_idx:
which episode to return examples from
:param entry_idx:
which example to return from the episode. Many datasets have only
single-entry episodes, so this defaults to zero.
... |
Get the specified episode and the specified entry in that episode. | def get(self, episode_idx, entry_idx=0):
"""
Get the specified episode and the specified entry in that episode.
:param episode_idx:
which episode to return examples from
:param entry_idx:
which example to return from the episode. Many datasets have only
... | [
"def",
"get",
"(",
"self",
",",
"episode_idx",
",",
"entry_idx",
"=",
"0",
")",
":",
"if",
"episode_idx",
">=",
"len",
"(",
"self",
".",
"data",
")",
":",
"return",
"{",
"'episode_done'",
":",
"True",
"}",
",",
"True",
"next_episode_idx_for_rank",
"=",
... | [
815,
4
] | [
840,
33
] | python | en | ['en', 'error', 'th'] | False |
DialogData.build_table | (self, entry) |
Packs an entry into an action-observation dictionary.
:param entry: a tuple in the form described in the class docstring.
|
Packs an entry into an action-observation dictionary. | def build_table(self, entry):
"""
Packs an entry into an action-observation dictionary.
:param entry: a tuple in the form described in the class docstring.
"""
if isinstance(entry, (dict, Message)):
# user is already provided things
if 'eval_labels' in en... | [
"def",
"build_table",
"(",
"self",
",",
"entry",
")",
":",
"if",
"isinstance",
"(",
"entry",
",",
"(",
"dict",
",",
"Message",
")",
")",
":",
"# user is already provided things",
"if",
"'eval_labels'",
"in",
"entry",
"or",
"'eval_label'",
"in",
"entry",
":",... | [
842,
4
] | [
914,
20
] | python | en | ['en', 'error', 'th'] | False |
StreamDialogData.share | (self) |
Share the stream.
|
Share the stream.
| def share(self):
"""
Share the stream.
"""
shared = super().share()
# also share reset method to allow datastream to be reset
shared['reset'] = self.reset
# share datafile and data for loading length if necessary
shared['datafile'] = self.datafile
... | [
"def",
"share",
"(",
"self",
")",
":",
"shared",
"=",
"super",
"(",
")",
".",
"share",
"(",
")",
"# also share reset method to allow datastream to be reset",
"shared",
"[",
"'reset'",
"]",
"=",
"self",
".",
"reset",
"# share datafile and data for loading length if nec... | [
984,
4
] | [
997,
21
] | python | en | ['en', 'error', 'th'] | False |
StreamDialogData._load | (self, data_loader, datafile) |
Load data generator into data field.
|
Load data generator into data field.
| def _load(self, data_loader, datafile):
"""
Load data generator into data field.
"""
self.data = self._data_generator(data_loader, datafile) | [
"def",
"_load",
"(",
"self",
",",
"data_loader",
",",
"datafile",
")",
":",
"self",
".",
"data",
"=",
"self",
".",
"_data_generator",
"(",
"data_loader",
",",
"datafile",
")"
] | [
999,
4
] | [
1003,
63
] | python | en | ['en', 'error', 'th'] | False |
StreamDialogData._data_generator | (self, data_loader, datafile) |
Generate data using the iterator over tuples constructed by data_loader.
|
Generate data using the iterator over tuples constructed by data_loader.
| def _data_generator(self, data_loader, datafile):
"""
Generate data using the iterator over tuples constructed by data_loader.
"""
self.is_reset = False
idx = 0
while True:
for episode in self._read_episode(data_loader(datafile)):
# We only sha... | [
"def",
"_data_generator",
"(",
"self",
",",
"data_loader",
",",
"datafile",
")",
":",
"self",
".",
"is_reset",
"=",
"False",
"idx",
"=",
"0",
"while",
"True",
":",
"for",
"episode",
"in",
"self",
".",
"_read_episode",
"(",
"data_loader",
"(",
"datafile",
... | [
1005,
4
] | [
1021,
40
] | python | en | ['en', 'error', 'th'] | False |
StreamDialogData.load_length | (self) |
Calculate the length of the dataset and caches it in a file.
Note that this can take some time for large datasets. Episode and entry indexes
cannot be specified during streaming.
|
Calculate the length of the dataset and caches it in a file. | def load_length(self):
"""
Calculate the length of the dataset and caches it in a file.
Note that this can take some time for large datasets. Episode and entry indexes
cannot be specified during streaming.
"""
datafiles = self.datafile if type(self.datafile) is tuple els... | [
"def",
"load_length",
"(",
"self",
")",
":",
"datafiles",
"=",
"self",
".",
"datafile",
"if",
"type",
"(",
"self",
".",
"datafile",
")",
"is",
"tuple",
"else",
"[",
"self",
".",
"datafile",
"]",
"length_file",
"=",
"datafiles",
"[",
"0",
"]",
"+",
"\... | [
1023,
4
] | [
1043,
41
] | python | en | ['en', 'error', 'th'] | False |
StreamDialogData.num_examples | (self) |
Return the number of examples in the data.
|
Return the number of examples in the data.
| def num_examples(self):
"""
Return the number of examples in the data.
"""
if not self.num_exs:
self.num_eps, self.num_exs = self.load_length()
return self.num_exs | [
"def",
"num_examples",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"num_exs",
":",
"self",
".",
"num_eps",
",",
"self",
".",
"num_exs",
"=",
"self",
".",
"load_length",
"(",
")",
"return",
"self",
".",
"num_exs"
] | [
1045,
4
] | [
1051,
27
] | python | en | ['en', 'error', 'th'] | False |
StreamDialogData.num_episodes | (self) |
Return the number of episodes in the data.
|
Return the number of episodes in the data.
| def num_episodes(self):
"""
Return the number of episodes in the data.
"""
if not self.num_eps:
self.num_eps, self.num_exs = self.load_length()
return self.num_eps | [
"def",
"num_episodes",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"num_eps",
":",
"self",
".",
"num_eps",
",",
"self",
".",
"num_exs",
"=",
"self",
".",
"load_length",
"(",
")",
"return",
"self",
".",
"num_eps"
] | [
1053,
4
] | [
1059,
27
] | python | en | ['en', 'error', 'th'] | False |
StreamDialogData.get | (self) |
Get the next entry from the stream.
When episode is done returns first entry of next episode.
|
Get the next entry from the stream. | def get(self):
"""
Get the next entry from the stream.
When episode is done returns first entry of next episode.
"""
if self.cur_episode is self._FIRST_PASS:
# first go around, always read off the episode
# maybe lock this line
self.cur_episod... | [
"def",
"get",
"(",
"self",
")",
":",
"if",
"self",
".",
"cur_episode",
"is",
"self",
".",
"_FIRST_PASS",
":",
"# first go around, always read off the episode",
"# maybe lock this line",
"self",
".",
"cur_episode",
"=",
"next",
"(",
"self",
".",
"data",
")",
"if"... | [
1067,
4
] | [
1090,
60
] | python | en | ['en', 'error', 'th'] | False |
StreamDialogData.reset | (self) |
Reset the datastream to its beginning.
|
Reset the datastream to its beginning.
| def reset(self):
"""
Reset the datastream to its beginning.
"""
if self.reset_data is not None:
# auxiliary instance, reset main datastream
self.data = self.reset_data()
elif not self.is_reset:
# if main instance is not reset, reset datastream
... | [
"def",
"reset",
"(",
"self",
")",
":",
"if",
"self",
".",
"reset_data",
"is",
"not",
"None",
":",
"# auxiliary instance, reset main datastream",
"self",
".",
"data",
"=",
"self",
".",
"reset_data",
"(",
")",
"elif",
"not",
"self",
".",
"is_reset",
":",
"# ... | [
1092,
4
] | [
1105,
24
] | python | en | ['en', 'error', 'th'] | False |
FbDeprecatedDialogTeacher.share | (self) |
Share the data and canidates.
|
Share the data and canidates.
| def share(self):
"""
Share the data and canidates.
"""
shared = super().share()
shared['cands'] = self.cands
return shared | [
"def",
"share",
"(",
"self",
")",
":",
"shared",
"=",
"super",
"(",
")",
".",
"share",
"(",
")",
"shared",
"[",
"'cands'",
"]",
"=",
"self",
".",
"cands",
"return",
"shared"
] | [
1177,
4
] | [
1183,
21
] | python | en | ['en', 'error', 'th'] | False |
FbDeprecatedDialogTeacher.label_candidates | (self) |
Return the candidates.
|
Return the candidates.
| def label_candidates(self):
"""
Return the candidates.
"""
return self.cands | [
"def",
"label_candidates",
"(",
"self",
")",
":",
"return",
"self",
".",
"cands"
] | [
1185,
4
] | [
1189,
25
] | python | en | ['en', 'error', 'th'] | False |
FbDeprecatedDialogTeacher.load_cands | (self, path) |
Load a global fixed set of candidates.
The candidates will be provided by the teacher for every example (the true
labels for a specific example are also added to this set, so that it's possible
to get the right answer).
|
Load a global fixed set of candidates. | def load_cands(self, path):
"""
Load a global fixed set of candidates.
The candidates will be provided by the teacher for every example (the true
labels for a specific example are also added to this set, so that it's possible
to get the right answer).
"""
if path... | [
"def",
"load_cands",
"(",
"self",
",",
"path",
")",
":",
"if",
"path",
"is",
"None",
":",
"return",
"None",
"cands",
"=",
"[",
"]",
"lines_have_ids",
"=",
"False",
"cands_are_replies",
"=",
"False",
"cnt",
"=",
"0",
"with",
"PathManager",
".",
"open",
... | [
1191,
4
] | [
1228,
20
] | python | en | ['en', 'error', 'th'] | False |
FbDeprecatedDialogTeacher.setup_data | (self, path) | r"""
Read data in the fbdialog format.
Returns ``((x,y,r,c), new_episode?)`` tuples.
``x`` represents a query, ``y`` represents the labels, ``r`` represents
any reward, and ``c`` represents any label_candidates.
The example above will be translated into the following tuples:
... | r"""
Read data in the fbdialog format. | def setup_data(self, path):
r"""
Read data in the fbdialog format.
Returns ``((x,y,r,c), new_episode?)`` tuples.
``x`` represents a query, ``y`` represents the labels, ``r`` represents
any reward, and ``c`` represents any label_candidates.
The example above will be tra... | [
"def",
"setup_data",
"(",
"self",
",",
"path",
")",
":",
"logging",
".",
"info",
"(",
"f\"loading fbdialog data: {path}\"",
")",
"with",
"PathManager",
".",
"open",
"(",
"path",
",",
"encoding",
"=",
"'utf-8'",
")",
"as",
"read",
":",
"start",
"=",
"True",... | [
1230,
4
] | [
1340,
46
] | python | cy | ['en', 'cy', 'hi'] | False |
ParlAIDialogTeacher.share | (self) |
Share the episodes.
|
Share the episodes.
| def share(self):
"""
Share the episodes.
"""
shared = super().share()
shared['episodes'] = self.episodes
return shared | [
"def",
"share",
"(",
"self",
")",
":",
"shared",
"=",
"super",
"(",
")",
".",
"share",
"(",
")",
"shared",
"[",
"'episodes'",
"]",
"=",
"self",
".",
"episodes",
"return",
"shared"
] | [
1416,
4
] | [
1422,
21
] | python | en | ['en', 'error', 'th'] | False |
ParlAIDialogTeacher.num_examples | (self) |
Return the number of examples from the data.
|
Return the number of examples from the data.
| def num_examples(self):
"""
Return the number of examples from the data.
"""
return self.num_exs | [
"def",
"num_examples",
"(",
"self",
")",
":",
"return",
"self",
".",
"num_exs"
] | [
1424,
4
] | [
1428,
27
] | python | en | ['en', 'error', 'th'] | False |
ParlAIDialogTeacher.num_episodes | (self) |
Return the number of episodes from the data.
|
Return the number of episodes from the data.
| def num_episodes(self):
"""
Return the number of episodes from the data.
"""
return len(self.episodes) | [
"def",
"num_episodes",
"(",
"self",
")",
":",
"return",
"len",
"(",
"self",
".",
"episodes",
")"
] | [
1430,
4
] | [
1434,
33
] | python | en | ['en', 'error', 'th'] | False |
ParlAIDialogTeacher.get | (self, episode_idx, entry_idx=None) |
Get a specific example from the dataset.
|
Get a specific example from the dataset.
| def get(self, episode_idx, entry_idx=None):
"""
Get a specific example from the dataset.
"""
return self.episodes[episode_idx][entry_idx] | [
"def",
"get",
"(",
"self",
",",
"episode_idx",
",",
"entry_idx",
"=",
"None",
")",
":",
"return",
"self",
".",
"episodes",
"[",
"episode_idx",
"]",
"[",
"entry_idx",
"]"
] | [
1436,
4
] | [
1440,
52
] | python | en | ['en', 'error', 'th'] | False |
ConversationTeacher.share | (self) |
Share the episodes.
|
Share the episodes.
| def share(self):
"""
Share the episodes.
"""
shared = super().share()
shared['episodes'] = self.episodes
return shared | [
"def",
"share",
"(",
"self",
")",
":",
"shared",
"=",
"super",
"(",
")",
".",
"share",
"(",
")",
"shared",
"[",
"'episodes'",
"]",
"=",
"self",
".",
"episodes",
"return",
"shared"
] | [
1547,
4
] | [
1553,
21
] | python | en | ['en', 'error', 'th'] | False |
ConversationTeacher.num_examples | (self) |
Return the number of examples from the data.
|
Return the number of examples from the data.
| def num_examples(self):
"""
Return the number of examples from the data.
"""
return self.num_exs | [
"def",
"num_examples",
"(",
"self",
")",
":",
"return",
"self",
".",
"num_exs"
] | [
1555,
4
] | [
1559,
27
] | python | en | ['en', 'error', 'th'] | False |
ConversationTeacher.num_episodes | (self) |
Return the number of episodes from the data.
|
Return the number of episodes from the data.
| def num_episodes(self):
"""
Return the number of episodes from the data.
"""
return len(self.episodes) | [
"def",
"num_episodes",
"(",
"self",
")",
":",
"return",
"len",
"(",
"self",
".",
"episodes",
")"
] | [
1561,
4
] | [
1565,
33
] | python | en | ['en', 'error', 'th'] | False |
ConversationTeacher.get | (self, episode_idx, entry_idx=None) |
Get a specific example from the dataset.
|
Get a specific example from the dataset.
| def get(self, episode_idx, entry_idx=None):
"""
Get a specific example from the dataset.
"""
return Message(self.episodes[episode_idx][entry_idx]) | [
"def",
"get",
"(",
"self",
",",
"episode_idx",
",",
"entry_idx",
"=",
"None",
")",
":",
"return",
"Message",
"(",
"self",
".",
"episodes",
"[",
"episode_idx",
"]",
"[",
"entry_idx",
"]",
")"
] | [
1567,
4
] | [
1571,
61
] | python | en | ['en', 'error', 'th'] | False |
AbstractImageTeacher.get_available_image_mode_names | (self) |
Available image model names.
resnet and resnext variants available from the ImageLoader. resnext101_XXXXX_wsl
is the open-sourced FB AI model (960m images, 1.5k hashtags, finetuned on
ImageNet).
|
Available image model names. | def get_available_image_mode_names(self):
"""
Available image model names.
resnet and resnext variants available from the ImageLoader. resnext101_XXXXX_wsl
is the open-sourced FB AI model (960m images, 1.5k hashtags, finetuned on
ImageNet).
"""
available_model_na... | [
"def",
"get_available_image_mode_names",
"(",
"self",
")",
":",
"available_model_names",
"=",
"ImageLoader",
".",
"get_available_model_names",
"(",
")",
"return",
"[",
"'no_image_model'",
",",
"'raw'",
",",
"'ascii'",
"]",
"+",
"available_model_names"
] | [
1694,
4
] | [
1703,
73
] | python | en | ['en', 'error', 'th'] | False |
AbstractImageTeacher._validate_image_mode_name | (self, a) |
Validate the image_mode passed in.
Needed because image_mode used elsewhere in ParlAI is not always consistent with
what the image teacher allows.
|
Validate the image_mode passed in. | def _validate_image_mode_name(self, a):
"""
Validate the image_mode passed in.
Needed because image_mode used elsewhere in ParlAI is not always consistent with
what the image teacher allows.
"""
if not isinstance(a, str):
raise argparse.ArgumentTypeError(
... | [
"def",
"_validate_image_mode_name",
"(",
"self",
",",
"a",
")",
":",
"if",
"not",
"isinstance",
"(",
"a",
",",
"str",
")",
":",
"raise",
"argparse",
".",
"ArgumentTypeError",
"(",
"'%s must be a string representing image model name'",
"%",
"a",
")",
"available_mod... | [
1705,
4
] | [
1722,
16
] | python | en | ['en', 'error', 'th'] | False |
AbstractImageTeacher.image_id_key | (self) |
Which key in the input data dict objects uniquely identify each image.
Common image keys are "image_id" or "image_num". May be implemented by subclass.
|
Which key in the input data dict objects uniquely identify each image. | def image_id_key(self):
"""
Which key in the input data dict objects uniquely identify each image.
Common image keys are "image_id" or "image_num". May be implemented by subclass.
"""
return 'image_id' | [
"def",
"image_id_key",
"(",
"self",
")",
":",
"return",
"'image_id'"
] | [
1750,
4
] | [
1756,
25
] | python | en | ['en', 'error', 'th'] | False |
AbstractImageTeacher.text_key | (self) |
Which key in the input data dict objects identifies the text.
Common keys are "text" or "comment". May be implemented by subclass.
|
Which key in the input data dict objects identifies the text. | def text_key(self):
"""
Which key in the input data dict objects identifies the text.
Common keys are "text" or "comment". May be implemented by subclass.
"""
return 'text' | [
"def",
"text_key",
"(",
"self",
")",
":",
"return",
"'text'"
] | [
1759,
4
] | [
1765,
21
] | python | en | ['en', 'error', 'th'] | False |
AbstractImageTeacher.image_id_to_image_path | (self, image_id) |
Get the path of the image on disk.
Must be implemented by subclass.
|
Get the path of the image on disk. | def image_id_to_image_path(self, image_id):
"""
Get the path of the image on disk.
Must be implemented by subclass.
"""
pass | [
"def",
"image_id_to_image_path",
"(",
"self",
",",
"image_id",
")",
":",
"pass"
] | [
1768,
4
] | [
1774,
12
] | python | en | ['en', 'error', 'th'] | False |
AbstractImageTeacher.get_data_path | (self, opt) |
Determines path to the data file.
|
Determines path to the data file.
| def get_data_path(self, opt):
"""
Determines path to the data file.
"""
task_name = opt['task'].split(':')[1] if ':' in opt['task'] else opt['task']
data_path = os.path.join(opt['datapath'], task_name)
return data_path | [
"def",
"get_data_path",
"(",
"self",
",",
"opt",
")",
":",
"task_name",
"=",
"opt",
"[",
"'task'",
"]",
".",
"split",
"(",
"':'",
")",
"[",
"1",
"]",
"if",
"':'",
"in",
"opt",
"[",
"'task'",
"]",
"else",
"opt",
"[",
"'task'",
"]",
"data_path",
"=... | [
1776,
4
] | [
1782,
24
] | python | en | ['en', 'error', 'th'] | False |
AbstractImageTeacher.get_image_path | (self, opt) |
Return the path to the data directory and to the image directory.
Is based on opt fields: task, datatype (train, valid, test), datapath.
Subclass can override this.
|
Return the path to the data directory and to the image directory. | def get_image_path(self, opt):
"""
Return the path to the data directory and to the image directory.
Is based on opt fields: task, datatype (train, valid, test), datapath.
Subclass can override this.
"""
data_path = self.get_data_path(opt)
if opt.get('image_path... | [
"def",
"get_image_path",
"(",
"self",
",",
"opt",
")",
":",
"data_path",
"=",
"self",
".",
"get_data_path",
"(",
"opt",
")",
"if",
"opt",
".",
"get",
"(",
"'image_path'",
",",
"None",
")",
":",
"image_path",
"=",
"opt",
"[",
"'image_path'",
"]",
"else"... | [
1784,
4
] | [
1799,
25
] | python | en | ['en', 'error', 'th'] | False |
AbstractImageTeacher.get_image_features_path | (self, task, image_model_name, dt) |
Image features for the dataset images are stored here.
Can be overriden in subclass to use custom paths. Image features can be manually
copied into this directory or in the case of ImageLoader eligible models, they
will be built and stored here if not already there.
|
Image features for the dataset images are stored here. | def get_image_features_path(self, task, image_model_name, dt):
"""
Image features for the dataset images are stored here.
Can be overriden in subclass to use custom paths. Image features can be manually
copied into this directory or in the case of ImageLoader eligible models, they
... | [
"def",
"get_image_features_path",
"(",
"self",
",",
"task",
",",
"image_model_name",
",",
"dt",
")",
":",
"# In default implementation, self.data_path already has task name added",
"image_features_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"data_path"... | [
1801,
4
] | [
1816,
9
] | python | en | ['en', 'error', 'th'] | False |
AbstractImageTeacher.is_image_mode_buildable | (self, model_name) |
Is buildable if features can be calculated by ImageLoader.
Users may wish to compute features for the dataset offline and use in the model,
in which case, the image model should return False and get_image_features()
should be overriden in subclass.
|
Is buildable if features can be calculated by ImageLoader. | def is_image_mode_buildable(self, model_name):
"""
Is buildable if features can be calculated by ImageLoader.
Users may wish to compute features for the dataset offline and use in the model,
in which case, the image model should return False and get_image_features()
should be ov... | [
"def",
"is_image_mode_buildable",
"(",
"self",
",",
"model_name",
")",
":",
"return",
"model_name",
"in",
"ImageLoader",
".",
"get_available_model_names",
"(",
")"
] | [
1818,
4
] | [
1826,
68
] | python | en | ['en', 'error', 'th'] | False |
AbstractImageTeacher.load_data | (self, data_path, opt) |
Loading the data file, which is the index to the images and text.
It is often a .json file with the name of the <datatype>.json (i.e.
train.json). Stores in self.data.
Can be override by subclass.
|
Loading the data file, which is the index to the images and text. | def load_data(self, data_path, opt):
"""
Loading the data file, which is the index to the images and text.
It is often a .json file with the name of the <datatype>.json (i.e.
train.json). Stores in self.data.
Can be override by subclass.
"""
dt = DatatypeHelper... | [
"def",
"load_data",
"(",
"self",
",",
"data_path",
",",
"opt",
")",
":",
"dt",
"=",
"DatatypeHelper",
".",
"fold",
"(",
"opt",
"[",
"'datatype'",
"]",
")",
"# Sometimes file is named \"val\" instead of \"valid\"",
"if",
"dt",
"not",
"in",
"[",
"'train'",
",",
... | [
1828,
4
] | [
1859,
24
] | python | en | ['en', 'error', 'th'] | False |
AbstractImageTeacher.setup_image_features | (self, data_path) |
Load text and image data.
The image features all live in dicts by default in <data_path>/
image_features/ but get_image_features_path() above can be overriden by
subclass to put them elsewhere.
In the (very odd) case that the resnet or resnext dicts (models
buildable u... |
Load text and image data. | def setup_image_features(self, data_path):
"""
Load text and image data.
The image features all live in dicts by default in <data_path>/
image_features/ but get_image_features_path() above can be overriden by
subclass to put them elsewhere.
In the (very odd) case that t... | [
"def",
"setup_image_features",
"(",
"self",
",",
"data_path",
")",
":",
"if",
"self",
".",
"image_mode",
"in",
"[",
"'raw'",
",",
"'ascii'",
"]",
":",
"self",
".",
"image_features_dict",
"=",
"None",
"self",
".",
"image_loader",
"=",
"ImageLoader",
"(",
"s... | [
1861,
4
] | [
1910,
17
] | python | en | ['en', 'error', 'th'] | False |
AbstractImageTeacher._build_image_features_dict | (self, data_path, dt, store_dict_path) |
Build resne(x)t image features with ImageLoader.
(Or anything handleable by ImageLoader) and save to path. Only called if we
haven't already built the dict before.
|
Build resne(x)t image features with ImageLoader. | def _build_image_features_dict(self, data_path, dt, store_dict_path):
"""
Build resne(x)t image features with ImageLoader.
(Or anything handleable by ImageLoader) and save to path. Only called if we
haven't already built the dict before.
"""
image_features_dict = {}
... | [
"def",
"_build_image_features_dict",
"(",
"self",
",",
"data_path",
",",
"dt",
",",
"store_dict_path",
")",
":",
"image_features_dict",
"=",
"{",
"}",
"total",
"=",
"len",
"(",
"self",
".",
"data",
")",
"import",
"tqdm",
"pbar",
"=",
"tqdm",
".",
"tqdm",
... | [
1912,
4
] | [
1945,
34
] | python | en | ['en', 'error', 'th'] | False |
AbstractImageTeacher.get_image_features | (self, example) |
Get image features for example.
Can be overrided in subclass for different behavior. For large datasets, it may
be more appropriate to use the ImageLoader.load() method to load image features
(as this is essentially streaming the features from disk, so that we do not have
to lo... |
Get image features for example. | def get_image_features(self, example):
"""
Get image features for example.
Can be overrided in subclass for different behavior. For large datasets, it may
be more appropriate to use the ImageLoader.load() method to load image features
(as this is essentially streaming the featur... | [
"def",
"get_image_features",
"(",
"self",
",",
"example",
")",
":",
"if",
"self",
".",
"image_mode",
"in",
"[",
"'raw'",
",",
"'ascii'",
"]",
":",
"try",
":",
"image",
"=",
"self",
".",
"image_loader",
".",
"load",
"(",
"self",
".",
"image_id_to_image_pa... | [
1957,
4
] | [
1982,
29
] | python | en | ['en', 'error', 'th'] | False |
AbstractImageTeacher.get | (self, episode_idx, entry_idx=0) |
Override this in subclass if your data should be handled in a different format.
|
Override this in subclass if your data should be handled in a different format.
| def get(self, episode_idx, entry_idx=0):
"""
Override this in subclass if your data should be handled in a different format.
"""
example = self.data[episode_idx]
image_features = self.get_image_features(example)
return {
'labels': [example[self.text_key]],
... | [
"def",
"get",
"(",
"self",
",",
"episode_idx",
",",
"entry_idx",
"=",
"0",
")",
":",
"example",
"=",
"self",
".",
"data",
"[",
"episode_idx",
"]",
"image_features",
"=",
"self",
".",
"get_image_features",
"(",
"example",
")",
"return",
"{",
"'labels'",
"... | [
1984,
4
] | [
1995,
9
] | python | en | ['en', 'error', 'th'] | False |
MultiTaskTeacher.num_examples | (self) |
Return the number of examples.
|
Return the number of examples.
| def num_examples(self):
"""
Return the number of examples.
"""
if not hasattr(self, 'num_exs'):
# num_examples is sum of all examples in all tasks
tasks_num_exs = [t.num_examples() for t in self.tasks]
if any(num is None for num in tasks_num_exs):
... | [
"def",
"num_examples",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'num_exs'",
")",
":",
"# num_examples is sum of all examples in all tasks",
"tasks_num_exs",
"=",
"[",
"t",
".",
"num_examples",
"(",
")",
"for",
"t",
"in",
"self",
".",
... | [
2052,
4
] | [
2063,
27
] | python | en | ['en', 'error', 'th'] | False |
MultiTaskTeacher.num_episodes | (self) |
Return the number of episodes.
|
Return the number of episodes.
| def num_episodes(self):
"""
Return the number of episodes.
"""
if not hasattr(self, 'num_eps'):
# num_episodes is sum of all num_episodes in all tasks
tasks_num_eps = [t.num_episodes() for t in self.tasks]
if any(num is None for num in tasks_num_eps):
... | [
"def",
"num_episodes",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'num_eps'",
")",
":",
"# num_episodes is sum of all num_episodes in all tasks",
"tasks_num_eps",
"=",
"[",
"t",
".",
"num_episodes",
"(",
")",
"for",
"t",
"in",
"self",
".... | [
2065,
4
] | [
2076,
27
] | python | en | ['en', 'error', 'th'] | False |
MultiTaskTeacher.observe | (self, observation) |
Make an observation.
|
Make an observation.
| def observe(self, observation):
"""
Make an observation.
"""
return self.tasks[self.task_idx].observe(observation) | [
"def",
"observe",
"(",
"self",
",",
"observation",
")",
":",
"return",
"self",
".",
"tasks",
"[",
"self",
".",
"task_idx",
"]",
".",
"observe",
"(",
"observation",
")"
] | [
2078,
4
] | [
2082,
61
] | python | en | ['en', 'error', 'th'] | False |
MultiTaskTeacher.act | (self) |
Act on the previous observation.
|
Act on the previous observation.
| def act(self):
"""
Act on the previous observation.
"""
if self.new_task:
self.new_task = False
if self.random:
# select random teacher
self.task_idx = random.choices(
self.task_choices, cum_weights=self.cum_task... | [
"def",
"act",
"(",
"self",
")",
":",
"if",
"self",
".",
"new_task",
":",
"self",
".",
"new_task",
"=",
"False",
"if",
"self",
".",
"random",
":",
"# select random teacher",
"self",
".",
"task_idx",
"=",
"random",
".",
"choices",
"(",
"self",
".",
"task... | [
2084,
4
] | [
2108,
16
] | python | en | ['en', 'error', 'th'] | False |
MultiTaskTeacher.epoch_done | (self) |
Return whether all subtasks are completed.
|
Return whether all subtasks are completed.
| def epoch_done(self):
"""
Return whether all subtasks are completed.
"""
for t in self.tasks:
if not t.epoch_done():
return False
return True | [
"def",
"epoch_done",
"(",
"self",
")",
":",
"for",
"t",
"in",
"self",
".",
"tasks",
":",
"if",
"not",
"t",
".",
"epoch_done",
"(",
")",
":",
"return",
"False",
"return",
"True"
] | [
2110,
4
] | [
2117,
19
] | python | en | ['en', 'error', 'th'] | False |
MultiTaskTeacher.report | (self) |
Report aggregated metrics across all subtasks.
|
Report aggregated metrics across all subtasks.
| def report(self):
"""
Report aggregated metrics across all subtasks.
"""
return aggregate_named_reports(
{t.getID(): t.report() for t in self.tasks},
micro_average=self.opt.get('aggregate_micro', False),
) | [
"def",
"report",
"(",
"self",
")",
":",
"return",
"aggregate_named_reports",
"(",
"{",
"t",
".",
"getID",
"(",
")",
":",
"t",
".",
"report",
"(",
")",
"for",
"t",
"in",
"self",
".",
"tasks",
"}",
",",
"micro_average",
"=",
"self",
".",
"opt",
".",
... | [
2120,
4
] | [
2127,
9
] | python | en | ['en', 'error', 'th'] | False |
MultiTaskTeacher.reset | (self) |
Reset all subtasks.
|
Reset all subtasks.
| def reset(self):
"""
Reset all subtasks.
"""
for t in self.tasks:
t.reset() | [
"def",
"reset",
"(",
"self",
")",
":",
"for",
"t",
"in",
"self",
".",
"tasks",
":",
"t",
".",
"reset",
"(",
")"
] | [
2129,
4
] | [
2134,
21
] | python | en | ['en', 'error', 'th'] | False |
MultiTaskTeacher.reset_metrics | (self) |
Reset metrics for each subtask.
|
Reset metrics for each subtask.
| def reset_metrics(self):
"""
Reset metrics for each subtask.
"""
for t in self.tasks:
t.reset_metrics() | [
"def",
"reset_metrics",
"(",
"self",
")",
":",
"for",
"t",
"in",
"self",
".",
"tasks",
":",
"t",
".",
"reset_metrics",
"(",
")"
] | [
2136,
4
] | [
2141,
29
] | python | en | ['en', 'error', 'th'] | False |
MultiTaskTeacher.share | (self) |
Shares this teacher by sharing each subtask.
|
Shares this teacher by sharing each subtask.
| def share(self):
"""
Shares this teacher by sharing each subtask.
"""
shared = {}
shared['class'] = type(self)
shared['opt'] = self.opt
shared['tasks'] = [t.share() for t in self.tasks]
return shared | [
"def",
"share",
"(",
"self",
")",
":",
"shared",
"=",
"{",
"}",
"shared",
"[",
"'class'",
"]",
"=",
"type",
"(",
"self",
")",
"shared",
"[",
"'opt'",
"]",
"=",
"self",
".",
"opt",
"shared",
"[",
"'tasks'",
"]",
"=",
"[",
"t",
".",
"share",
"(",... | [
2143,
4
] | [
2151,
21
] | python | en | ['en', 'error', 'th'] | False |
MultiTaskTeacher.shutdown | (self) |
Shutdown each agent.
|
Shutdown each agent.
| def shutdown(self):
"""
Shutdown each agent.
"""
for t in self.tasks:
t.shutdown() | [
"def",
"shutdown",
"(",
"self",
")",
":",
"for",
"t",
"in",
"self",
".",
"tasks",
":",
"t",
".",
"shutdown",
"(",
")"
] | [
2153,
4
] | [
2158,
24
] | python | en | ['en', 'error', 'th'] | False |
ChunkTeacher.get_num_samples | (self, opt: Opt) |
[Abstract] Return the number of samples.
Returns a tuple of (num_examples, num_episodes) based on the data split.
|
[Abstract] Return the number of samples. | def get_num_samples(self, opt: Opt) -> Tuple[int, int]:
"""
[Abstract] Return the number of samples.
Returns a tuple of (num_examples, num_episodes) based on the data split.
"""
pass | [
"def",
"get_num_samples",
"(",
"self",
",",
"opt",
":",
"Opt",
")",
"->",
"Tuple",
"[",
"int",
",",
"int",
"]",
":",
"pass"
] | [
2224,
4
] | [
2230,
12
] | python | en | ['en', 'error', 'th'] | False |
ChunkTeacher.get_fold_chunks | (self, opt: Opt) |
[Abstract] Return a list of chunk IDs (integer).
Given the datatype (train/test/valid), return the list of chunk IDs that
correspond to that split.
|
[Abstract] Return a list of chunk IDs (integer). | def get_fold_chunks(self, opt: Opt) -> List[int]: # type: ignore
"""
[Abstract] Return a list of chunk IDs (integer).
Given the datatype (train/test/valid), return the list of chunk IDs that
correspond to that split.
"""
pass | [
"def",
"get_fold_chunks",
"(",
"self",
",",
"opt",
":",
"Opt",
")",
"->",
"List",
"[",
"int",
"]",
":",
"# type: ignore",
"pass"
] | [
2233,
4
] | [
2240,
12
] | python | en | ['en', 'error', 'th'] | False |
ChunkTeacher.get_buffersize | (self) |
Size of buffer.
Override this in your child class to change the buffer size.
|
Size of buffer. | def get_buffersize(self):
"""
Size of buffer.
Override this in your child class to change the buffer size.
"""
return 100000 | [
"def",
"get_buffersize",
"(",
"self",
")",
":",
"return",
"100000"
] | [
2242,
4
] | [
2248,
21
] | python | en | ['en', 'error', 'th'] | False |
ChunkTeacher._setup_data | (self, datatype) |
Passthrough.
|
Passthrough.
| def _setup_data(self, datatype):
"""
Passthrough.
"""
pass | [
"def",
"_setup_data",
"(",
"self",
",",
"datatype",
")",
":",
"pass"
] | [
2265,
4
] | [
2269,
12
] | python | en | ['en', 'error', 'th'] | False |
ChunkTeacher._enqueue_request | (self) |
Queue a request for loading to the data loader.
|
Queue a request for loading to the data loader.
| def _enqueue_request(self):
"""
Queue a request for loading to the data loader.
"""
self.data_loader.request_load(self.receive_data, self.get_chunk, ()) | [
"def",
"_enqueue_request",
"(",
"self",
")",
":",
"self",
".",
"data_loader",
".",
"request_load",
"(",
"self",
".",
"receive_data",
",",
"self",
".",
"get_chunk",
",",
"(",
")",
")"
] | [
2283,
4
] | [
2287,
76
] | python | en | ['en', 'error', 'th'] | False |
ChunkTeacher.receive_data | (self, future) |
Loads data.
Load data into self.samples until buffersize is reached.
|
Loads data. | def receive_data(self, future):
"""
Loads data.
Load data into self.samples until buffersize is reached.
"""
output = future.result()
if output is None:
return
chunk_output, chunk_reset_cnt = output
if chunk_output is None:
return
... | [
"def",
"receive_data",
"(",
"self",
",",
"future",
")",
":",
"output",
"=",
"future",
".",
"result",
"(",
")",
"if",
"output",
"is",
"None",
":",
"return",
"chunk_output",
",",
"chunk_reset_cnt",
"=",
"output",
"if",
"chunk_output",
"is",
"None",
":",
"r... | [
2289,
4
] | [
2314,
31
] | python | en | ['en', 'error', 'th'] | False |
ChunkTeacher._enqueue_chunks | (self) |
Shuffles and queues fold chunks for loading.
|
Shuffles and queues fold chunks for loading.
| def _enqueue_chunks(self):
"""
Shuffles and queues fold chunks for loading.
"""
if self.is_train:
self.rng.shuffle(self.fold_chunks)
# save the reset count at the time a chunk was queued
reset_cnt = self.reset_counter.value()
for c in self.fold_chunks:... | [
"def",
"_enqueue_chunks",
"(",
"self",
")",
":",
"if",
"self",
".",
"is_train",
":",
"self",
".",
"rng",
".",
"shuffle",
"(",
"self",
".",
"fold_chunks",
")",
"# save the reset count at the time a chunk was queued",
"reset_cnt",
"=",
"self",
".",
"reset_counter",
... | [
2316,
4
] | [
2325,
43
] | python | en | ['en', 'error', 'th'] | False |
ChunkTeacher.load_from_chunk | (self, chunk_idx: int) |
[Abstract] Given the chunk index, load examples from that chunk.
Return a list of tuples. The function `_create_message` will take these tuples
to form the Message object that is returned by the teacher.
|
[Abstract] Given the chunk index, load examples from that chunk. | def load_from_chunk(self, chunk_idx: int) -> List[ChunkOutput]:
"""
[Abstract] Given the chunk index, load examples from that chunk.
Return a list of tuples. The function `_create_message` will take these tuples
to form the Message object that is returned by the teacher.
"""
... | [
"def",
"load_from_chunk",
"(",
"self",
",",
"chunk_idx",
":",
"int",
")",
"->",
"List",
"[",
"ChunkOutput",
"]",
":",
"pass"
] | [
2328,
4
] | [
2335,
12
] | python | en | ['en', 'error', 'th'] | False |
ChunkTeacher.create_message | (self, queue_output: ChunkOutput, entry_idx=0) |
[Abstract] Given the tuple output of the queue, return an act.
May depend on entry index if queue output is a multi-turn episode.
|
[Abstract] Given the tuple output of the queue, return an act. | def create_message(self, queue_output: ChunkOutput, entry_idx=0) -> 'Message':
"""
[Abstract] Given the tuple output of the queue, return an act.
May depend on entry index if queue output is a multi-turn episode.
"""
pass | [
"def",
"create_message",
"(",
"self",
",",
"queue_output",
":",
"ChunkOutput",
",",
"entry_idx",
"=",
"0",
")",
"->",
"'Message'",
":",
"pass"
] | [
2338,
4
] | [
2344,
12
] | python | en | ['en', 'error', 'th'] | False |
ChunkTeacher.get_chunk | (self) |
Refill the buffer.
|
Refill the buffer.
| def get_chunk(self):
"""
Refill the buffer.
"""
if self.chunks.empty():
if self.is_train:
self._enqueue_chunks()
else:
# if we're in valid/test, we need to actually signal the end
return None
next_chunk, chu... | [
"def",
"get_chunk",
"(",
"self",
")",
":",
"if",
"self",
".",
"chunks",
".",
"empty",
"(",
")",
":",
"if",
"self",
".",
"is_train",
":",
"self",
".",
"_enqueue_chunks",
"(",
")",
"else",
":",
"# if we're in valid/test, we need to actually signal the end",
"ret... | [
2346,
4
] | [
2364,
38
] | python | en | ['en', 'error', 'th'] | False |
Tickformatstop.dtickrange | (self) |
range [*min*, *max*], where "min", "max" - dtick values which
describe some zoom level, it is possible to omit "min" or "max"
value by passing "null"
The 'dtickrange' property is an info array that may be specified as:
* a list or tuple of 2 elements where:
(0) The... |
range [*min*, *max*], where "min", "max" - dtick values which
describe some zoom level, it is possible to omit "min" or "max"
value by passing "null"
The 'dtickrange' property is an info array that may be specified as:
* a list or tuple of 2 elements where:
(0) The... | def dtickrange(self):
"""
range [*min*, *max*], where "min", "max" - dtick values which
describe some zoom level, it is possible to omit "min" or "max"
value by passing "null"
The 'dtickrange' property is an info array that may be specified as:
* a list or tuple... | [
"def",
"dtickrange",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"dtickrange\"",
"]"
] | [
15,
4
] | [
31,
33
] | python | en | ['en', 'error', 'th'] | False |
Tickformatstop.enabled | (self) |
Determines whether or not this stop is used. If `false`, this
stop is ignored even within its `dtickrange`.
The 'enabled' property must be specified as a bool
(either True, or False)
Returns
-------
bool
|
Determines whether or not this stop is used. If `false`, this
stop is ignored even within its `dtickrange`.
The 'enabled' property must be specified as a bool
(either True, or False) | def enabled(self):
"""
Determines whether or not this stop is used. If `false`, this
stop is ignored even within its `dtickrange`.
The 'enabled' property must be specified as a bool
(either True, or False)
Returns
-------
bool
"""
ret... | [
"def",
"enabled",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"enabled\"",
"]"
] | [
40,
4
] | [
52,
30
] | python | en | ['en', 'error', 'th'] | False |
Tickformatstop.name | (self) |
When used in a template, named items are created in the output
figure in addition to any items the figure already has in this
array. You can modify these items in the output figure by
making your own item with `templateitemname` matching this
`name` alongside your modifications ... |
When used in a template, named items are created in the output
figure in addition to any items the figure already has in this
array. You can modify these items in the output figure by
making your own item with `templateitemname` matching this
`name` alongside your modifications ... | def name(self):
"""
When used in a template, named items are created in the output
figure in addition to any items the figure already has in this
array. You can modify these items in the output figure by
making your own item with `templateitemname` matching this
`name` al... | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"name\"",
"]"
] | [
61,
4
] | [
79,
27
] | python | en | ['en', 'error', 'th'] | False |
Tickformatstop.templateitemname | (self) |
Used to refer to a named item in this array in the template.
Named items from the template will be created even without a
matching item in the input figure, but you can modify one by
making an item with `templateitemname` matching its `name`,
alongside your modifications (includ... |
Used to refer to a named item in this array in the template.
Named items from the template will be created even without a
matching item in the input figure, but you can modify one by
making an item with `templateitemname` matching its `name`,
alongside your modifications (includ... | def templateitemname(self):
"""
Used to refer to a named item in this array in the template.
Named items from the template will be created even without a
matching item in the input figure, but you can modify one by
making an item with `templateitemname` matching its `name`,
... | [
"def",
"templateitemname",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"templateitemname\"",
"]"
] | [
88,
4
] | [
107,
39
] | python | en | ['en', 'error', 'th'] | False |
Tickformatstop.value | (self) |
string - dtickformat for described zoom level, the same as
"tickformat"
The 'value' property is a string and must be specified as:
- A string
- A number that will be converted to a string
Returns
-------
str
|
string - dtickformat for described zoom level, the same as
"tickformat"
The 'value' property is a string and must be specified as:
- A string
- A number that will be converted to a string | def value(self):
"""
string - dtickformat for described zoom level, the same as
"tickformat"
The 'value' property is a string and must be specified as:
- A string
- A number that will be converted to a string
Returns
-------
str
"... | [
"def",
"value",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"value\"",
"]"
] | [
116,
4
] | [
129,
28
] | python | en | ['en', 'error', 'th'] | False |
Tickformatstop.__init__ | (
self,
arg=None,
dtickrange=None,
enabled=None,
name=None,
templateitemname=None,
value=None,
**kwargs
) |
Construct a new Tickformatstop object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of :class:`plotly.graph_objs.scattergeo.mar
ker.colorbar.Tickformatstop`
dtickrange
range [... |
Construct a new Tickformatstop object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of :class:`plotly.graph_objs.scattergeo.mar
ker.colorbar.Tickformatstop`
dtickrange
range [... | def __init__(
self,
arg=None,
dtickrange=None,
enabled=None,
name=None,
templateitemname=None,
value=None,
**kwargs
):
"""
Construct a new Tickformatstop object
Parameters
----------
arg
dict... | [
"def",
"__init__",
"(",
"self",
",",
"arg",
"=",
"None",
",",
"dtickrange",
"=",
"None",
",",
"enabled",
"=",
"None",
",",
"name",
"=",
"None",
",",
"templateitemname",
"=",
"None",
",",
"value",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"sup... | [
172,
4
] | [
282,
34
] | python | en | ['en', 'error', 'th'] | False |
compare_init_model_opts | (opt: Opt, curr_opt: Opt) |
Print loud warning when `init_model` opts differ from previous configuration.
|
Print loud warning when `init_model` opts differ from previous configuration.
| def compare_init_model_opts(opt: Opt, curr_opt: Opt):
"""
Print loud warning when `init_model` opts differ from previous configuration.
"""
if opt.get('init_model') is None:
return
opt['init_model'] = modelzoo_path(opt['datapath'], opt['init_model'])
optfile = opt['init_model'] + '.opt'
... | [
"def",
"compare_init_model_opts",
"(",
"opt",
":",
"Opt",
",",
"curr_opt",
":",
"Opt",
")",
":",
"if",
"opt",
".",
"get",
"(",
"'init_model'",
")",
"is",
"None",
":",
"return",
"opt",
"[",
"'init_model'",
"]",
"=",
"modelzoo_path",
"(",
"opt",
"[",
"'d... | [
200,
0
] | [
262,
9
] | python | en | ['en', 'error', 'th'] | False |
create_agent_from_model_file | (model_file, opt_overrides=None) |
Load agent from model file if it exists.
:param opt_overrides:
An optional dict of option overrides can also be provided.
:return:
The agent
|
Load agent from model file if it exists. | def create_agent_from_model_file(model_file, opt_overrides=None):
"""
Load agent from model file if it exists.
:param opt_overrides:
An optional dict of option overrides can also be provided.
:return:
The agent
"""
opt = {}
add_datapath_and_model_args(opt)
opt['model_fil... | [
"def",
"create_agent_from_model_file",
"(",
"model_file",
",",
"opt_overrides",
"=",
"None",
")",
":",
"opt",
"=",
"{",
"}",
"add_datapath_and_model_args",
"(",
"opt",
")",
"opt",
"[",
"'model_file'",
"]",
"=",
"modelzoo_path",
"(",
"opt",
".",
"get",
"(",
"... | [
265,
0
] | [
280,
42
] | python | en | ['en', 'error', 'th'] | False |
create_agent_from_opt_file | (opt: Opt) |
Load agent options and module from file if opt file exists.
Checks to see if file exists opt['model_file'] + ".opt"; if so, load up the
options from the file and use that to create an agent, loading the model
type from that file and overriding any options specified in that file when
instantiating ... |
Load agent options and module from file if opt file exists. | def create_agent_from_opt_file(opt: Opt):
"""
Load agent options and module from file if opt file exists.
Checks to see if file exists opt['model_file'] + ".opt"; if so, load up the
options from the file and use that to create an agent, loading the model
type from that file and overriding any optio... | [
"def",
"create_agent_from_opt_file",
"(",
"opt",
":",
"Opt",
")",
":",
"model_file",
"=",
"opt",
"[",
"'model_file'",
"]",
"optfile",
"=",
"model_file",
"+",
"'.opt'",
"if",
"not",
"PathManager",
".",
"exists",
"(",
"optfile",
")",
":",
"return",
"None",
"... | [
283,
0
] | [
354,
37
] | python | en | ['en', 'error', 'th'] | False |
create_agent | (opt: Opt, requireModelExists=False) |
Create an agent from the options ``model``, ``model_params`` and ``model_file``.
The input is either of the form
``parlai.agents.ir_baseline.agents:IrBaselineAgent`` (i.e. the path
followed by the class name) or else just ``ir_baseline`` which
assumes the path above, and a class name suffixed with... |
Create an agent from the options ``model``, ``model_params`` and ``model_file``. | def create_agent(opt: Opt, requireModelExists=False):
"""
Create an agent from the options ``model``, ``model_params`` and ``model_file``.
The input is either of the form
``parlai.agents.ir_baseline.agents:IrBaselineAgent`` (i.e. the path
followed by the class name) or else just ``ir_baseline`` whi... | [
"def",
"create_agent",
"(",
"opt",
":",
"Opt",
",",
"requireModelExists",
"=",
"False",
")",
":",
"if",
"opt",
".",
"get",
"(",
"'datapath'",
",",
"None",
")",
"is",
"None",
":",
"add_datapath_and_model_args",
"(",
"opt",
")",
"if",
"opt",
".",
"get",
... | [
373,
0
] | [
418,
79
] | python | en | ['en', 'error', 'th'] | False |
create_agent_from_shared | (shared_agent) |
Instantiate an agent from the default `shared` params.
:param shared_agent:
should include an `opt` dictionary and agent `class`, along with
whatever other parameters the agent needs to instantiate.
|
Instantiate an agent from the default `shared` params. | def create_agent_from_shared(shared_agent):
"""
Instantiate an agent from the default `shared` params.
:param shared_agent:
should include an `opt` dictionary and agent `class`, along with
whatever other parameters the agent needs to instantiate.
"""
opt = copy.deepcopy(shared_agent... | [
"def",
"create_agent_from_shared",
"(",
"shared_agent",
")",
":",
"opt",
"=",
"copy",
".",
"deepcopy",
"(",
"shared_agent",
"[",
"'opt'",
"]",
")",
"a",
"=",
"shared_agent",
"[",
"'class'",
"]",
"(",
"opt",
",",
"shared_agent",
")",
"return",
"a"
] | [
423,
0
] | [
433,
12
] | python | en | ['en', 'error', 'th'] | False |
create_agents_from_shared | (shared) |
Create agents based on shared data.
:param shared: `list` of `dict` objects created by calling e.g.
[a.share() for a in agents].
Returns a list of instantiated agents.
|
Create agents based on shared data. | def create_agents_from_shared(shared):
"""
Create agents based on shared data.
:param shared: `list` of `dict` objects created by calling e.g.
[a.share() for a in agents].
Returns a list of instantiated agents.
"""
shared_agents = []
for shared_agent in shared:
agent = crea... | [
"def",
"create_agents_from_shared",
"(",
"shared",
")",
":",
"shared_agents",
"=",
"[",
"]",
"for",
"shared_agent",
"in",
"shared",
":",
"agent",
"=",
"create_agent_from_shared",
"(",
"shared_agent",
")",
"shared_agents",
".",
"append",
"(",
"agent",
")",
"retur... | [
436,
0
] | [
449,
24
] | python | en | ['en', 'error', 'th'] | False |
Agent.observe | (self, observation) |
Receive an observation/action dict.
|
Receive an observation/action dict.
| def observe(self, observation):
"""
Receive an observation/action dict.
"""
self.observation = observation
return observation | [
"def",
"observe",
"(",
"self",
",",
"observation",
")",
":",
"self",
".",
"observation",
"=",
"observation",
"return",
"observation"
] | [
71,
4
] | [
76,
26
] | python | en | ['en', 'error', 'th'] | False |
Agent.act | (self) |
Return an observation/action dict based upon given observation.
|
Return an observation/action dict based upon given observation.
| def act(self):
"""
Return an observation/action dict based upon given observation.
"""
if hasattr(self, 'observation') and self.observation is not None:
logging.info(f'agent received observation:\n{self.observation}')
t = {}
t['text'] = 'hello, teacher!'
... | [
"def",
"act",
"(",
"self",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"'observation'",
")",
"and",
"self",
".",
"observation",
"is",
"not",
"None",
":",
"logging",
".",
"info",
"(",
"f'agent received observation:\\n{self.observation}'",
")",
"t",
"=",
"{",... | [
78,
4
] | [
88,
16
] | python | en | ['en', 'error', 'th'] | False |
Agent.getID | (self) |
Return the agent ID.
|
Return the agent ID.
| def getID(self):
"""
Return the agent ID.
"""
return self.id | [
"def",
"getID",
"(",
"self",
")",
":",
"return",
"self",
".",
"id"
] | [
90,
4
] | [
94,
22
] | python | en | ['en', 'error', 'th'] | False |
Agent.epoch_done | (self) |
Return whether the epoch is done or not.
:rtype: boolean
|
Return whether the epoch is done or not. | def epoch_done(self):
"""
Return whether the epoch is done or not.
:rtype: boolean
"""
return False | [
"def",
"epoch_done",
"(",
"self",
")",
":",
"return",
"False"
] | [
96,
4
] | [
102,
20
] | python | en | ['en', 'error', 'th'] | False |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.