Bases: OutputVectorDataDescription
, InputImageDataDescription
DataDescription for Classification data
Functions
get_index_for_name
Returns the index of the given output entry name(s) as int or list of indices
Source code in niceml/data/datadescriptions/clsdatadescription.py
| def get_index_for_name(
self, name: Union[str, List[str]]
) -> Optional[Union[int, List[int]]]:
"""Returns the index of the given output entry name(s) as int or list of indices"""
if isinstance(name, list):
return super().get_index_for_name(name)
if self.use_multitargets:
index_list = []
for cur_idx, cur_class in enumerate(self.classes):
if isinstance(cur_class, dict):
if cur_class["name"] == name or name in cur_class.get(
"subclasses", []
):
index_list.append(cur_idx)
elif cur_class == name:
index_list.append(cur_idx)
return index_list or None
return super().get_index_for_name(name)
|
get_input_channel_count()
Returns the number of input channels
Source code in niceml/data/datadescriptions/clsdatadescription.py
| def get_input_channel_count(self) -> int:
"""Returns the number of input channels"""
return self.channel_count
|
get_output_entry_names
Returns the names of the target classes
Source code in niceml/data/datadescriptions/clsdatadescription.py
| def get_output_entry_names(self) -> List[str]:
"""Returns the names of the target classes"""
class_name_list = []
for cls in self.classes:
if isinstance(cls, dict):
class_name_list.append(cls["name"])
else:
class_name_list.append(cls)
return class_name_list
|
get_output_size
Returns the size of the output
Source code in niceml/data/datadescriptions/clsdatadescription.py
| def get_output_size(self) -> int:
"""Returns the size of the output"""
if self.use_binary and len(self.classes) != 2:
raise Exception(f"Cannot use binary with {len(self.classes)} given!")
return 1 if self.use_binary else len(self.classes)
|