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

TypeError: forward() takes 2 positional arguments but 3 were given,flownetc_flow2 = self.flownetc(x)[0].why!!!! #286

Open
zzk1212 opened this issue Mar 15, 2024 · 0 comments

Comments

@zzk1212
Copy link

zzk1212 commented Mar 15, 2024

截图 2024-03-15 17-50-21
截图 2024-03-15 17-53-06
I spent a lot of time and still couldn't solve this problem. Has anyone encountered this problem? Can you provide a solution? Thank you so much!

Tasks

No tasks being tracked yet.

import argparse

parser = argparse.ArgumentParser(description='Calculate volume of a cylinder')
parser.add_argument("--rgb_max", default=1)
parser.add_argument("--fp16", default=True)
args = parser.parse_args() # 获取所有参数

flownet2 = FlowNet2(args=args)

获取 conv1 的第一个子模块

first_module = flownet2.flownetc.conv1[0] # 假设 conv1 是一个包含一个子模块的 Sequential 对象

获取第一个子模块的输入通道数

expected_channels = first_module.in_channels
print("模型的期望输入通道数:", expected_channels)

创建符合期望通道数的随机输入张量

batch_size = 1
channels = 3
height = 64
width = 64
inputs = torch.randn(batch_size, channels, height, width) # 随机生成一个输入张量

将输入张量传递给模型获取输出

output = flownet2(inputs)

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

1 participant