I fixed it. I am also using instancenorm. Now I got another type of error that I’ve never come across before. I am currently working on it. Note that my data is 1D vector.

save_handler = SAVE[format.upper()]

KeyError: ‘PNG’

This function causes the error:

def save(self, fp, format=None, **params):
“”"
Saves this image under the given filename.  If no format is
specified, the format to use is determined from the filename
extension, if possible.
    Keyword options can be used to provide additional instructions
    to the writer. If a writer doesn't recognise an option, it is
    silently ignored. The available options are described in the
    :doc:`image format documentation
    <../handbook/image-file-formats>` for each writer.

    You can use a file object instead of a filename. In this case,
    you must always specify the format. The file object must
    implement the ``seek``, ``tell``, and ``write``
    methods, and be opened in binary mode.

    :param fp: A filename (string), pathlib.Path object or file object.
    :param format: Optional format override.  If omitted, the
       format to use is determined from the filename extension.
       If a file object was used instead of a filename, this
       parameter should always be used.
    :param params: Extra parameters to the image writer.
    :returns: None
    :exception ValueError: If the output format could not be determined
       from the file name.  Use the format option to solve this.
    :exception OSError: If the file could not be written.  The file
       may have been created, and may contain partial data.
    """

    filename = ""
    open_fp = False
    if isPath(fp):
        filename = fp
        open_fp = True
    elif isinstance(fp, Path):
        filename = str(fp)
        open_fp = True
    if not filename and hasattr(fp, "name") and isPath(fp.name):
        # only set the name for metadata purposes
        filename = fp.name

    # may mutate self!
    self._ensure_mutable()

    save_all = params.pop("save_all", False)
    self.encoderinfo = params
    self.encoderconfig = ()

    preinit()

    ext = os.path.splitext(filename)[1].lower()

    if not format:
        if ext not in EXTENSION:
            init()
        try:
            format = EXTENSION[ext]
        except KeyError as e:
            raise ValueError(f"unknown file extension: {ext}") from e

    if format.upper() not in SAVE:
        init()
    if save_all:
        save_handler = SAVE_ALL[format.upper()]
    else:
        save_handler = SAVE[format.upper()]

    if open_fp:
        if params.get("append", False):
            # Open also for reading ("+"), because TIFF save_all
            # writer needs to go back and edit the written data.
            fp = builtins.open(filename, "r+b")
        else:
            fp = builtins.open(filename, "w+b")

    try:
        save_handler(self, fp, filename)
    finally:
        # do what we can to clean up
        if open_fp:
            fp.close()