Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about the CorrDiff Example #704

Closed
MyGitHub-G opened this issue Nov 1, 2024 · 4 comments
Closed

Question about the CorrDiff Example #704

MyGitHub-G opened this issue Nov 1, 2024 · 4 comments

Comments

@MyGitHub-G
Copy link

when i run python train.py, the error:

Error executing job with overrides: []
Traceback (most recent call last):
  File "/public/home/shizhm2050/gexl/modulus/examples/generative/corrdiff/train.py", line 104, in main
    img_out_channels = len(dataset.output_channels())
  File "/public/home/shizhm2050/gexl/modulus/examples/generative/corrdiff/datasets/cwb.py", line 448, in output_channels
    return [out_channels[i] for i in self.out_channels]
  File "/public/home/shizhm2050/gexl/modulus/examples/generative/corrdiff/datasets/cwb.py", line 448, in <listcomp>
    return [out_channels[i] for i in self.out_channels]
IndexError: list index out of range

what is the reason?

and

cwb_train.yaml文件中in_channels: [0, 1, 2, 3, 4, 9, 10, 11, 12, 17, 18, 19]是什么意思,为什么不是0~19,代表20个变量呢

@MyGitHub-G
Copy link
Author

cwb.py ZarrDataset class:

def input_channels(self):
        """Metadata for the input channels. A list of dictionaries, one for each channel"""
        in_channels = self._dataset.input_channels()
        # print(in_channels)  # 20个输入变量
        # print(self.in_channels) # [0, 1, 2, 3, 4, 9, 10, 11, 12, 17, 18, 19]
        in_channels = [in_channels[i] for i in self.in_channels]
        return in_channels

    def output_channels(self):
        """Metadata for the output channels. A list of dictionaries, one for each channel"""
        out_channels = self._dataset.output_channels()
        print(out_channels) 
        # [ChannelMetadata(name='maximum_radar_reflectivity', level='', auxiliary=False), 
        #   ChannelMetadata(name='temperature_2m', level='', auxiliary=False), 
        #   ChannelMetadata(name='eastward_wind_10m', level='', auxiliary=False), 
        #   ChannelMetadata(name='northward_wind_10m', level='', auxiliary=False)]
        # print(self.out_channels) #[0, 17, 18, 19]
        # return [out_channels[i] for i in self.out_channels]
        return [out_channels[i] for i in range(len(self.out_channels))]

in the output_channels function, the self.out_channels is [0, 17, 18, 19], not [0,1,2,3]
17 results the IndexError
i changed thereturn [out_channels[i] for i in self.out_channels]to return [out_channels[i] for i in range(len(self.out_channels))]
is it a bug?

@MyGitHub-G
Copy link
Author

cwb.py ZarrDataset class getitem function:

# channels
        input = input[self.in_channels, :, :]
        # target = target[self.out_channels, :, :]
        target = target[range(len(self.out_channels)), :, :]

target = target[self.out_channels, :, :] results error IndexError: index 17 is out of bounds for axis 0 with size 4
changed to target = target[range(len(self.out_channels)), :, :]
is it a bug?

@zomosky
Copy link

zomosky commented Nov 1, 2024

cwb.py ZarrDataset class getitem function:

# channels
        input = input[self.in_channels, :, :]
        # target = target[self.out_channels, :, :]
        target = target[range(len(self.out_channels)), :, :]

target = target[self.out_channels, :, :] results error IndexError: index 17 is out of bounds for axis 0 with size 4 changed to target = target[range(len(self.out_channels)), :, :] is it a bug?

I have changed it in the conf/yaml by cfg.dataset.out_channels = [0, 1, 2, 3], also the channels means the channels choice in the zarr, you can see channels by zarr.tree()

我也觉得这是一个bug,也有可能是之前的训练集的结构不一样导致的,可以直接在yaml或者运行的时候改变channel就行,因为作为output的输出的数据集size为4,所以可以设置为cfg.dataset.out_channels = [0, 1, 2, 3] 可以通过简单的zarr库和zarr.tree()方法查看zarr数据库的结构

import zarr as zr
zrpath = '/home/cwa_dataset/cwa_dataset.zarr'
ze = zr.open(zrpath, mode = 'r')
zr.load(zrpath)
group = zr.open_consolidated(zrpath)
ze = zr.open(zrpath, mode = 'r')
zr.tree(ze)

@MyGitHub-G
Copy link
Author

cwb.py ZarrDataset class getitem function:

# channels
        input = input[self.in_channels, :, :]
        # target = target[self.out_channels, :, :]
        target = target[range(len(self.out_channels)), :, :]

target = target[self.out_channels, :, :] results error IndexError: index 17 is out of bounds for axis 0 with size 4 changed to target = target[range(len(self.out_channels)), :, :] is it a bug?

I have changed it in the conf/yaml by cfg.dataset.out_channels = [0, 1, 2, 3], also the channels means the channels choice in the zarr, you can see channels by zarr.tree()

我也觉得这是一个bug,也有可能是之前的训练集的结构不一样导致的,可以直接在yaml或者运行的时候改变channel就行,因为作为output的输出的数据集size为4,所以可以设置为cfg.dataset.out_channels = [0, 1, 2, 3] 可以通过简单的zarr库和zarr.tree()方法查看zarr数据库的结构

import zarr as zr
zrpath = '/home/cwa_dataset/cwa_dataset.zarr'
ze = zr.open(zrpath, mode = 'r')
zr.load(zrpath)
group = zr.open_consolidated(zrpath)
ze = zr.open(zrpath, mode = 'r')
zr.tree(ze)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants