def CollectDatasetPair(self, data_pair: list): """ This function collect a data_pair from raw sentences and semantics. ATTENTION: [as_amr = true] does not support conversion with ConvertToTensorMatrices! :param data_pair:list: amr data_pair """ try: sentence: str = self.RemoveEnclosingAngleBracket( self._constants.SENTENCE_DELIM + ' ' + data_pair[0]).replace( '\n', '') semantic: str = self.EncloseWrongFormattedAMR(data_pair[1]) semantic = self.ForgeAmrSemanticString(semantic) if (not self._stringified_amr): semantic = self.ForgeMatrices(semantic) if isNotNone(semantic) and isNotNone(sentence): sentence = self._constants.START_SIGN + ' ' + sentence + ' ' + self._constants.END_SIGN return [sentence, semantic] else: return None except Exception as ex: template = "An exception of type {0} occurred in [DatasetProvider.CollectDatasetPair]. Arguments:\n{1!r}" message = template.format(type(ex).__name__, ex.args) print(message)
def LoadJson(self): """ This method parse a json file containing a list of amr and string pairs. """ try: sentence_lengths:list = [] semantic_lengths:list = [] pairs:list = [] with open(self.path, 'r+') as f: jsons = json.load(f) for elem in jsons: amr:str = elem['amr'] sent:str = elem['sent'] if isNotNone(amr) and isNotNone(sent): semantic_lengths.append(len(amr)) sentence_lengths.append(len(amr)) pairs.append([sent, amr]) return sentence_lengths, semantic_lengths, pairs except Exception as ex: template = "An exception of type {0} occurred in [FileReader.LoadJson]. Arguments:\n{1!r}" message = template.format(type(ex).__name__, ex.args) print(message)
def CollectLossFromHistory(self): """ This method collect the loss metric data from the history. """ try: loss_val: str = 'loss' if loss_val in self._history_keys: self._losses = [ s for s in self._history_keys if (loss_val == s) ] self._val_losses = [ s for s in self._history_keys if ('val' + loss_val in s) ] self._epochs = len(self._history.epoch) if len(self._losses) == 0 or len(self._val_losses) == 0: print('Loss is missing in history') return if isNotNone(self._losses) and isNotNone(self._val_losses): self._history_keys_list.remove(loss_val) self._history_keys_list.remove('val_' + loss_val) print("Found losses in history!") except Exception as ex: template = "An exception of type {0} occurred in [HistoryPlotter.CollectLossFromHistory]. Arguments:\n{1!r}" message = template.format(type(ex).__name__, ex.args) print(message)
def __init__(self, node_parenthesis: list = ['(', ')'], input_context: str = None, input_extension_dict: dict = {}, keep_opt_infos: bool = False): """ Class constructor collect all necessary parameters for the cleaning process. :param node_parenthesis:list: define node parenthesis :param input_context:str: input amr string :param input_extension_dict:dict: look up dictionairy :param keep_opt_infos:bool: switch allow to optional infos """ try: self.constants = Constants() self.keep_opt_info_encoding = keep_opt_infos if isNotNone(input_context): self.hasContext = True self.context = input_context if bool(input_extension_dict): self.hasExtentsionsDict = True self.extension_dict = input_extension_dict self.extension_keys_dict = self.extension_dict.keys() if isNotNone(node_parenthesis): self.node_parenthesis = node_parenthesis if (self.hasContext): self.GenerateCleanAMR() except Exception as ex: template = "An exception of type {0} occurred in [AMRCleaner.__init__]. Arguments:\n{1!r}" message = template.format(type(ex).__name__, ex.args) print(message)
def CollectAccFromHistory(self, name: str): """ This method collect the accuracy data from the history into 2 lists. :param name:str: name of the used acc metric """ try: acc_list: list = [] val_acc_list: list = [] name = re.sub('val_', '', name) if name in self._history_keys: acc_list = [s for s in self._history_keys if (name == s)] val_acc_list = [ s for s in self._history_keys if ('val_' + name == s) ] if isNotNone(acc_list) and isNotNone(val_acc_list): self._history_keys_list.remove(name) self._history_keys_list.remove('val_' + name) print("Found accuracy metrics in history!") return acc_list, val_acc_list except Exception as ex: template = "An exception of type {0} occurred in [HistoryPlotter.CollectAccFromHistory]. Arguments:\n{1!r}" message = template.format(type(ex).__name__, ex.args) print(message)
def __init__(self, model_description: str, path: str = None, history=None, save_it: bool = True, new_style: bool = False): """ The class constructor. Attention: File history plotting is not yet implemented! :param model_description:str: something to name the image unique and is also the file name :param path:str: path of a file containing a history :param history: a history :param save_it:bool: save the plot instead of showing :param new_style:bool: desired matplot lib standard or new style """ try: self._model_description = model_description if isNotNone( model_description) else 'undescribed_model' if isNotNone(path) and isNone(history): self._path: str = path self._using_history = False if isNotNone(history): self._history = history self._history_keys = history.history.keys() self._history_keys_list = list(self._history_keys) self._using_history = True self._new_style: bool = new_style self._save_it: bool = save_it except Exception as ex: template = "An exception of type {0} occurred in [HistoryPlotter.Constructor]. Arguments:\n{1!r}" message = template.format(type(ex).__name__, ex.args) print(message)
def __init__(self, path:str =None, seperator_regex:str =None): """ The class constructor check for valid input and store it for local usage. :param path:str: path of file with string content :param seperator_regex:str: an optional regex string that allow to split an amr dataset at each occurence """ try: self.constants = Constants() self.path = path if isNotNone(path) else None self.seperator_regex = seperator_regex if isNotNone(seperator_regex) else self.constants.ELEMENT_SPLIT_REGEX except Exception as ex: template = "An exception of type {0} occurred in [FileReader.Constructor]. Arguments:\n{1!r}" message = template.format(type(ex).__name__, ex.args) print(message)
def SavingCorpus(self, data_pair: list): """ This function build a simple concatenation string containing a sentence and a semantic. :param data_pair:list: a list containing pairs of cleaned sentence with sentences flags and cleaned corresponding semantics with semantics flags. """ try: if isNotNone(data_pair) and isStr(data_pair[0]) and isNotNone( data_pair[1]): return data_pair[0] + data_pair[1] else: return None except Exception as ex: template = "An exception of type {0} occurred in [FileWriter.SavingCorpus]. Arguments:\n{1!r}" message = template.format(type(ex).__name__, ex.args) print(message)
def NavigateState(self, graph_root: AnyNode, node: AnyNode): """ This function sets the state of a node depending on its (position in the) corresponding tree (-> DAG review as Tree) :param graph_root:AnyNode: tree root :param node:AnyNode: node from tree you want to update """ try: if isNotNone(node.label) and isNone(node.content): label = node.label regex = str('\\b' + label + '\\b') desired = [] tmp_desired = findall(graph_root, lambda node: node.label in label) for i in tmp_desired: match = re.findall(regex, i.label) if len(match) > 0: desired.append(i) if (len(desired) < 1): print(node.state) elif (len(desired) == 1): self.NormalState(node) else: node.followerNodes = desired[0].followerNodes node.hasFollowerNodes = desired[0].hasFollowerNodes node.hasInputNode = desired[0].hasInputNode node.state = 'navigator' node.name = 'navigator_' + str(node.id) else: self.NormalState(node) except Exception as ex: template = "An exception of type {0} occurred in [TParser.NavigateState]. Arguments:\n{1!r}" message = template.format(type(ex).__name__, ex.args) print(message)
def RemoveExtensionsAndFlags(self, node_elements: list): """ This function removes all word extensions and flag elements in a given node_sequence :param node_elements:list: split elements defining the node sequence """ try: results = [] if isNotNone(node_elements): for node_element in node_elements: if isInStr("-", node_element) or isInStr( ":", node_element): if isInStr("-", node_element) and isNotInStr( ":", node_element): sub_sequence = node_element[0:node_element. rfind('-')] if (len(sub_sequence) > 0): results.append(sub_sequence) else: continue else: if (len(node_element) > 0): results.append(node_element) return results except Exception as ex: template = "An exception of type {0} occurred in [TParser.RemoveExtensionsAndFlags]. Arguments:\n{1!r}" message = template.format(type(ex).__name__, ex.args) print(message)
def LoadNdArray(self, path:str = None): """ This method auto load a numpy nd array txt file which was saved with SaveNdArrayToTxt! :param path:str: this is a optional path instead of the initial path from constructor. """ try: path = path if isNotNone(path) else self._path f = open(path) shape_line = f.readline() f.close() shape_match = re.match(self._shape_regex, shape_line) shape_str = shape_match.group(2) if not ',)' in shape_str: shape_tupe = tuple(map(int, shape_str[1:-1].split(', '))) return np.loadtxt(path).reshape(shape_tupe) else: shape_tupe = tuple(map(int, shape_str[1:-2].split(', '))) return np.loadtxt(path).reshape(shape_tupe) except Exception as ex: template = "An exception of type {0} occurred in [NumpyDatasetHandler.Load3DNdArray]. Arguments:\n{1!r}" message = template.format(type(ex).__name__, ex.args) print(message) print(ex)
def HandleSingleDataPair(self, pair): """ This method process a single dataset. It'll be passed to the AMR cleaner pipe, the length restriction will be processed. :param pair: a dataset pair """ try: data_pair = self.CollectDatasetPair(pair) if isNotNone(data_pair): if (not self._stringified_amr): edges_dim = data_pair[1][0][0].shape[0] if (self._min_cardinality <= edges_dim and edges_dim <= self._max_cardinality): return [ data_pair, edges_dim, len(data_pair[0]), len(data_pair[0].split(" ")) ] # Return structure [datapair, pair_cardinality, pair_max_chars, pair_max_words] else: return None else: return data_pair else: return None except Exception as ex: template = "An exception of type {0} occurred in [DatasetProvider.HandleSingleDataPair]. Arguments:\n{1!r}" message = template.format(type(ex).__name__, ex.args) print(message)
def Extract(self): """ This function collect the AMR-String-Representation and the corresponding sentence from AMR corpus. """ try: sentence = '' semantic = '' result_pair = None sentence_found = False semantic_found = False sentence_lengths = [] semantic_lengths = [] pairs = [] for index, elem in enumerate(self.context): if (self.constants.SENTENCE_DELIM in elem): sentence = self.ExtractSentence(self.context, index) sentence_found = True if (self.constants.FILE_DELIM in elem and sentence_found): semantic = self.ExtractSemantic(self.context, index) semantic_found = True if sentence_found and semantic_found: result_pair = self.RestrictionCorpus(sentence, semantic) sentence_found = False semantic_found = False if isNotNone(result_pair): sentence_lengths.append(len(result_pair[0])) semantic_lengths.append(len(result_pair[1])) if isNotNone(result_pair[1]) and isNotNone( result_pair[1]): pairs.append(result_pair) result_pair = None if (len(sentence_lengths) == len(semantic_lengths) and isNotNone(pairs)): return [sentence_lengths, semantic_lengths, pairs] else: return None except Exception as ex: template = "An exception of type {0} occurred in [DatasetExtractor.Extract]. Arguments:\n{1!r}" message = template.format(type(ex).__name__, ex.args) print(message)
def CollectAllDatasetPairs(self, data_pairs: list, feedback: int = 10000): """ This function collect multiples pairs of semantic and sentence data as list of data pairs. For this case we pass arrays of raw sentences and semantics, where index i in both arrays point to a sentence and the corresponding semantic. Also the cardinalities will be collected. :param data_pairs:list: array of amr data pairs :param feedback:int: print out steps for bigger datasets """ try: self._max_chars_sentences = 0 self._max_words_sentences = 0 placeholder_pairs: list = [] dataset_pairs_sent_sem: list = [] if self._cpu_cores > 1: with Pool(self._cpu_cores) as p: placeholder_pairs = p.map(self.HandleSingleDataPair, data_pairs) else: for pair in data_pairs: placeholder_pairs.append(self.HandleSingleDataPair(pair)) if (self._stringified_amr): return placeholder_pairs else: print("START: Collect sample informations!") num_pairs: int = 0 print("Processable pairs = ", len(placeholder_pairs)) while placeholder_pairs: entry = placeholder_pairs.pop(0) num_pairs += 1 if isNotNone(entry): data_pair, edges_dim, pair_sent_chars_count, pair_sent_words_count = entry dataset_pairs_sent_sem.append(data_pair) self.CollectCardinalities(edges_dim) if (self._max_chars_sentences < pair_sent_chars_count): self._max_chars_sentences = pair_sent_chars_count if (self._max_words_sentences < pair_sent_words_count): self._max_words_sentences = pair_sent_words_count else: continue if (num_pairs % feedback == 0) and (num_pairs > feedback): print("Processed pairs: ", num_pairs) print("END: Collect sample informations!") return dataset_pairs_sent_sem except Exception as ex: template = "An exception of type {0} occurred in [DatasetProvider.CollectAllDatasetPairs]. Arguments:\n{1!r}" message = template.format(type(ex).__name__, ex.args) print(message)
def __init__(self, path: str = None): """ The class constructor. :param path:str: path of the file containing the history """ try: self._path = path if isNotNone(path) else None except Exception as ex: template = "An exception of type {0} occurred in [HistoryLoader.Constructor]. Arguments:\n{1!r}" message = template.format(type(ex).__name__, ex.args) print(message)
def __init__(self, nodes_context: list, vocab_size: int = 20000, max_sequence_length: int = 1000, show_feedback: bool = False): """ This class constructor stores all given parameters. Further it execute the word collecting process from the datasets node dictionairies. For further informations take a look at => https://nlp.stanford.edu/projects/glove/ => [Download pre-trained word vectors] :param nodes_context:list: the nodes context values of the dataset :param vocab_size:int: maximum number of words to keep, based on word frequency :param max_sequence_length:int: max length length over all sequences (padding) :param show_feedback:bool: switch allows to show process response on console or not """ try: print('~~~~~~ GloVe Dataset Preprocessor ~~~~~') self._node_words_list: list = None self._edge_matrices_fw: list = None self._edge_matrices_bw: list = None self._min: int = sys.maxsize self._max: int = -1 self._word_to_none_ratios: dict = {} self._sentences_dec_in: list = None self._sentences_tar_in: list = None self._word_index = None self._tokenizer_words = None self._show_response = show_feedback self.MAX_SEQUENCE_LENGTH = max_sequence_length if ( max_sequence_length > 0) else 1000 self._tokenizer = None if (vocab_size < 1) else Tokenizer( num_words=vocab_size, split=' ', char_level=False, filters='') print('Input/padding:\t\t => ', self.MAX_SEQUENCE_LENGTH) print('Vocab size:\t\t => ', vocab_size) if isNotNone(nodes_context): self.CollectDatasamples(nodes_context) if self._show_response: print('Collected decoder samples:\t => ', len(self._sentences_dec_in)) print('Generated target samples:\t => ', len(self._sentences_tar_in)) except Exception as ex: template = "An exception of type {0} occurred in [GloVeDatasetPreprocessor.Constructor]. Arguments:\n{1!r}" message = template.format(type(ex).__name__, ex.args) print(message)
def ReplaceKnownExtensions(self, in_context: str): """ Replace flags or content with a known entry in the extension dict. :param in_context:str: input string """ try: if ('-' in in_context and self.hasExtentsionsDict): look_up_control = self.CollectAllMatches( self.constants.EXTENSION_MULTI_WORD_REGEX, in_context) if (isNotNone(look_up_control) and isNotNone(self.extension_dict) and isDict(self.extension_dict)): for found in look_up_control: if len(found[0] ) > 0 and found[0] in self.extension_keys_dict: in_context = in_context.replace( found[0], self.extension_dict[found[0]]) return in_context except Exception as ex: template = "An exception of type {0} occurred in [ARMCleaner.ReplaceKnownExtensions]. Arguments:\n{1!r}" message = template.format(type(ex).__name__, ex.args) print(message)
def CollectDatasamples(self, datasets: list): """ This function collects all dataset word lists and edge matrices for further processing. Additionally it generates the lstm decoder targets from decoder inputs (depending on seq2seq encoder decoder)! :param datasets:list: pairs of cleaned amr datasets """ try: self._node_words_list = [] self._edge_matrices_fw = [] self._edge_matrices_bw = [] self._sentences_dec_in = [] self._sentences_tar_in = [] self._word_to_none_ratios = {} while len(datasets) > 0: dataset = datasets.pop() if isNotNone(dataset[1][0]) and len( dataset[1][0]) == 2 and len(dataset[1][0][0]) == len( dataset[1][0][1]): node_words = dataset[1][1] key = len(node_words) self._node_words_list.append(node_words) # Collect the none ratio values for bar chart summed_nones: int = sum(x is None for x in node_words) self._min = min(self._min, summed_nones) self._max = max(self._max, summed_nones) if not key in self._word_to_none_ratios: self._word_to_none_ratios[key] = [summed_nones] else: self._word_to_none_ratios[key].append(summed_nones) self._edge_matrices_fw.append(dataset[1][0][0]) self._edge_matrices_bw.append(dataset[1][0][1]) input_t_0 = self.ReplaceSentenceFlagAndDialogElements( dataset[0]) input_t_minus_1 = input_t_0.split(' ', 1)[1] self._sentences_dec_in.append(input_t_0) self._sentences_tar_in.append(input_t_minus_1) assert ( len(self._sentences_dec_in) == len(self._sentences_tar_in) ), "Dataset Error! Inputs counter doesn't match targets counter" except Exception as ex: template = "An exception of type {0} occurred in [GloVeDatasetPreprocessor.CollectDatasamples]. Arguments:\n{1!r}" message = template.format(type(ex).__name__, ex.args) print(message)
def __init__(self, folder_path: str, name: str, history): """ This constructor collect inputs and create the file path. :param folder_path:str: folder where to store the history :param name: name of the history file :param history: the history """ try: if isNotNone(folder_path): self._folder_path = folder_path self.MakeFolderIfMissing() path_seperator: str = '' if (folder_path[-1:] == '/') else '/' if isNotNone(name): self._file_path = folder_path + path_seperator + name if isNotNone(history): self.SaveKerasHistoryJson(history) except Exception as ex: template = "An exception of type {0} occurred in [HistorySaver.Constructor]. Arguments:\n{1!r}" message = template.format(type(ex).__name__, ex.args) print(message)
def StoreContext(self): """ This function saves a (stringified) context passed by class init into a given file. """ try: with open(self.out_path, 'w', encoding=self.writer_encoding) as fileOut: if isNotNone(self.context) and isStr(self.context): fileOut.write(self.context) fileOut.flush() except ValueError: print('WRONG INPUT FOR [FileWriter.StoreContext]') except Exception as ex: template = "An exception of type {0} occurred in [FileWriter.StoreContext]. Arguments:\n{1!r}" message = template.format(type(ex).__name__, ex.args) print(message)
def CollectLearningRatesFromHistory(self): """ This method collect the learning rate metric data from the history. """ try: lr_val: str = 'lr' if lr_val in self._history_keys: self._learning_rates = [ s for s in self._history_keys if (lr_val == s) ] if isNotNone(self._learning_rates): self._history_keys_list.remove(lr_val) print("Found learning rates in history!") except Exception as ex: template = "An exception of type {0} occurred in [HistoryPlotter.CollectLearningRatesFromHistory]. Arguments:\n{1!r}" message = template.format(type(ex).__name__, ex.args) print(message)
def StoreAMR(self): """ This function save the collected amr content to a given file. """ try: with open(self.out_path, 'w', encoding=self.writer_encoding) as fileOut: for i in range(len(self.dataset_pairs)): result = self.SavingCorpus(self.dataset_pairs[i]) if isNotNone(result): fileOut.write(result) fileOut.flush() except ValueError: print('WRONG INPUT FOR [FileWriter.StoreAMR]') except Exception as ex: template = "An exception of type {0} occurred in [FileWriter.StoreAMR]. Arguments:\n{1!r}" message = template.format(type(ex).__name__, ex.args) print(message)
def InputStrategySelection(self): """ This function processes the neighbourhood collection and selects a dimension conversion strategy for the desired returning dimension (2D or 3D) """ try: samples_results = self.GetAllSamplesAggregatedFeatures() if self.is_2d: return samples_results[0] else: if isNotNone(self.features.shape[0].value) and ( self.features.shape[0].value == 1): return K.expand_dims(samples_results[0], axis=0) else: return K.stack(samples_results) except Exception as ex: template = "An exception of type {0} occurred in [NeighbourhoodCollector.InputStrategySelection]. Arguments:\n{1!r}" message = template.format(type(ex).__name__, ex.args) print(message)
def Execute(self, features, neighbouring): """ This function executes the feature aggregation process for the next neighbouring step. """ try: AssertIsTensor(features) AssertIsTensor(neighbouring) self.features = features self.neighbouring = neighbouring if isNotNone(self.features.shape[0].value): return self.InputStrategySelection() # This is just for passing a mask to avoid slicing errors during batched training. return self.features except Exception as ex: template = "An exception of type {0} occurred in [NeighbourhoodCollector.Execute]. Arguments:\n{1!r}" message = template.format(type(ex).__name__, ex.args) print(message)
def __init__(self, input_path: str, in_output_extender: str = 'output', data_pairs: list = None, in_context: str = None): """ This is the constructor of the (File-)Writer class. Necessary is the input path only. Extender for the output path provide a default value. To provide 2 types of input you can set amr datapairs or various context of type string. If both is present the data pairs wil be preferred. :param input_path:str: path of the input file :param in_output_extender:str: extender to create output file from input path :param data_pairs:list: amr data pairs list like List<Array{sentence, semantic}> :param in_context:str: optional if no data pairs present use context """ try: self.constants = Constants() self.path = input_path AssertNotNone(self.path, msg='Given path for FileWriter was None!') self.out_path = setOrDefault(self.path + '.' + in_output_extender, self.constants.TYP_ERROR, isStr(in_output_extender)) print('Destination: ', self.out_path) if isNotNone(data_pairs): self.dataset_pairs = data_pairs #TODO: Missing Store Numpy Graphs self.StoreAMR() else: AssertNotNone(in_context, msg='Given input for FileWriter was None!') self.context = in_context self.StoreContext() except Exception as ex: template = "An exception of type {0} occurred in [FileWriter.__init__]. Arguments:\n{1!r}" message = template.format(type(ex).__name__, ex.args) print(message)
def __init__(self, dataset: dict, min_card: int, max_card: int, title: str = 'Cardinalities Occurences', short_title: str = 'Cardinality', y_label: str = 'Cardinalities', x_label: str = 'Occourences', path: str = None, save_it: bool = True): """ The class constructor. :param dataset:dict: dataset as dict :param min_card:int: minimum cardinality :param max_card:int: maximum cardinality :param title:str: plot image long title :param short_title:str: short title :param y_label:str: label for the y values :param x_label:str: label for the x values :param path:str: path where to store the plot image :param save_it:bool: save or show plot """ try: self._dataset: dict = dataset if isNotNone(dataset) else None self._min_card: int = min_card if (min_card > -1) else -1 self._max_card: int = max_card if (max_card > -1) else -1 self._title: str = title if isNotNone(title) else 'Untitled' self._short_title: str = short_title if isNotNone( short_title) else '' self._y_label: str = y_label if isNotNone(y_label) else 'Y_Value' self._x_label: str = x_label if isNotNone(x_label) else 'X_Value' self._path: str = path if isNotNone(path) else None self._save_it: bool = save_it if isNotNone(self._dataset): self.Print() except Exception as ex: template = "An exception of type {0} occurred in [BarChart.Constructor]. Arguments:\n{1!r}" message = template.format(type(ex).__name__, ex.args) print(message)
def DirectPlotHistory(self): """ This method helps to plot a keras history containing losses, accuracy and possibly least learning rates. """ try: fig_num: int = 1 ## Loss self.AccOrLossPlot( fig_num=fig_num, title='Model loss', metric='loss', axis_labels=['train', 'validation'], history_labels=['Loss', 'Epoch'], extender='loss_epoch_plot', train_val_lists=[self._losses, self._val_losses]) fig_num += 1 ## Top k Categorical Crossentropy if ('top_k_categorical_accuracy' in self._history_keys) and isNotNone( self._acc_topkcc_list) and isNotNone( self._val_acc_topkcc_list): self.AccOrLossPlot( fig_num=fig_num, title='Model Top k Categorical Accuracy', metric='top_k_categorical_accuracy', axis_labels=['train', 'validation'], history_labels=['Top k Categorical Accuracy', 'Epoch'], extender='top_k_categoriacal_epoch_plot', train_val_lists=[ self._acc_topkcc_list, self._val_acc_topkcc_list ]) fig_num += 1 ## Categorical Crossentropy if 'categorical_accuracy' in self._history_keys and isNotNone( self._acc_stdcc_list) and isNotNone( self._val_acc_stdcc_list): self.AccOrLossPlot( fig_num=fig_num, title='Model Categorical Accuracy', metric='categorical_accuracy', axis_labels=['train', 'validation'], history_labels=['Categorical Accuracy', 'Epoch'], extender='categoriacal_epoch_plot', train_val_lists=[ self._acc_stdcc_list, self._val_acc_stdcc_list ]) fig_num += 1 ## General if 'acc' in self._history_keys and isNotNone( self._acc_stdcc_list) and isNotNone( self._val_acc_stdcc_list): self.AccOrLossPlot(fig_num=fig_num, title='Model Accuracy', metric='accuracy', axis_labels=['train', 'validation'], history_labels=['Accuracy', 'Epoch'], extender='accuracy_epoch_plot', train_val_lists=[ self._acc_stdcc_list, self._val_acc_stdcc_list ]) fig_num += 1 if 'lr' in self._history_keys and isNotNone(self._learning_rates): self.LearningPlot(fig_num=fig_num, title='Model Learning Rate') fig_num += 1 except Exception as ex: template = "An exception of type {0} occurred in [HistoryPlotter.DirectPlotHistory]. Arguments:\n{1!r}" message = template.format(type(ex).__name__, ex.args) print(message)