Skip to content
Snippets Groups Projects
Commit 9d563182 authored by Iryna de Albuquerque Silva's avatar Iryna de Albuquerque Silva
Browse files

Defined JSON as default format for writing trainable parameters in external file

parent 19398e4a
No related branches found
No related tags found
3 merge requests!279v0.4.0,!253v0.4.0,!211Add show_graphview funcionality.
...@@ -24,20 +24,20 @@ def _retrieve_operator_attrs(node : aidge_core.Node) -> dict[str, int, float, bo ...@@ -24,20 +24,20 @@ def _retrieve_operator_attrs(node : aidge_core.Node) -> dict[str, int, float, bo
return node_attr_dict return node_attr_dict
def _create_dict(ordered_nodes : list[aidge_core.Node], write_trainable_params_ext : bool, write_trainable_params_embed : bool, params_file_format : str, path_trainable_params : str) -> dict[str, int, float, bool, None]: def _create_dict(ordered_nodes : list[aidge_core.Node], write_trainable_params_embed : bool, write_trainable_params_ext : bool, path_trainable_params : str, params_file_format : str) -> dict[str, int, float, bool, None]:
""" """
Creates a dictionary to store the information of a given ordered GraphView. Creates a dictionary to store the information of a given ordered GraphView.
:param ordered_nodes: A list with the GraphView's ordered nodes. :param ordered_nodes: A list with the GraphView's ordered nodes.
:type graph: list :type graph: list
:param write_trainable_params_ext: Whether or not to write the eventual trainable parameters of the Nodes in an external file.
:type write_trainable_params_ext: bool
:param write_trainable_params_embed: Whether or not to write the eventual trainable parameters of the Nodes in the same file as the dict (embed). :param write_trainable_params_embed: Whether or not to write the eventual trainable parameters of the Nodes in the same file as the dict (embed).
:type write_trainable_params_embed: bool :type write_trainable_params_embed: bool
:param params_file_format: Format of the external file used to store the Nodes' trainable parameters. Options: ``npz`` or ``json``. :param write_trainable_params_ext: Whether or not to write the eventual trainable parameters of the Nodes in an external file.
:type params_file_format: str :type write_trainable_params_ext: bool
:param path_trainable_params: Path of the external file used to store the Nodes' trainable parameters. :param path_trainable_params: Path of the external file used to store the Nodes' trainable parameters.
:type path_trainable_params: str :type path_trainable_params: str
:param params_file_format: Format of the external file used to store the Nodes' trainable parameters. Options: ``npz`` or ``json``.
:type params_file_format: str
:return: A dictionary with the GraphView description. :return: A dictionary with the GraphView description.
:rtype: dict[str, int, float, bool, None] :rtype: dict[str, int, float, bool, None]
...@@ -168,7 +168,7 @@ def _write_dict_json(graphview_dict : dict[str, int, float, bool, None], json_pa ...@@ -168,7 +168,7 @@ def _write_dict_json(graphview_dict : dict[str, int, float, bool, None], json_pa
return None return None
def gview_to_json(gview : aidge_core.GraphView, json_path : str, write_trainable_params_ext : bool = False, write_trainable_params_embed : bool = False, params_file_format : str = None) -> None: def gview_to_json(gview : aidge_core.GraphView, json_path : str, write_trainable_params_embed : bool = False, write_trainable_params_ext : bool = False, params_file_format : str = 'json') -> None:
""" """
Generates the description for a GraphView in the JSON format. Generates the description for a GraphView in the JSON format.
...@@ -176,11 +176,11 @@ def gview_to_json(gview : aidge_core.GraphView, json_path : str, write_trainable ...@@ -176,11 +176,11 @@ def gview_to_json(gview : aidge_core.GraphView, json_path : str, write_trainable
:type graph: aidge_core.GraphView :type graph: aidge_core.GraphView
:param json_path: Path to write JSON file. :param json_path: Path to write JSON file.
:type json_path: str :type json_path: str
:param write_trainable_params_ext: Whether or not to write the eventual trainable parameters of the Nodes in an external file.
:type write_trainable_params_ext: bool, optional
:param write_trainable_params_embed: Whether or not to write the eventual trainable parameters of the Nodes in the same file as the dict (embed). :param write_trainable_params_embed: Whether or not to write the eventual trainable parameters of the Nodes in the same file as the dict (embed).
:type write_trainable_params_embed: bool, optional :type write_trainable_params_embed: bool, optional
:param params_file_format: Format of the external file used to store the Nodes' trainable parameters. Options: ``npz`` or ``json``. Default = ``json``. Requires ``write_trainable_params_ext``. :param write_trainable_params_ext: Whether or not to write the eventual trainable parameters of the Nodes in an external file.
:type write_trainable_params_ext: bool, optional
:param params_file_format: Format of the external file used to store the Nodes' trainable parameters. Options: ``npz`` or ``json``. Default : ``json``. Requires ``write_trainable_params_ext``.
:type params_file_format: str, optional :type params_file_format: str, optional
""" """
...@@ -197,7 +197,7 @@ def gview_to_json(gview : aidge_core.GraphView, json_path : str, write_trainable ...@@ -197,7 +197,7 @@ def gview_to_json(gview : aidge_core.GraphView, json_path : str, write_trainable
ordered_nodes = gview.get_ordered_nodes() ordered_nodes = gview.get_ordered_nodes()
# Create dict from GraphView # Create dict from GraphView
graphview_dict = _create_dict(ordered_nodes, write_trainable_params_ext, write_trainable_params_embed, params_file_format, path_trainable_params) graphview_dict = _create_dict(ordered_nodes, write_trainable_params_embed, write_trainable_params_ext, path_trainable_params, params_file_format)
# Write dict to JSON # Write dict to JSON
_write_dict_json(graphview_dict, json_path) _write_dict_json(graphview_dict, json_path)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment