Pytorch implementation of FlowNet 2.0: Evolution of Optical Flow Estimation with Deep Networks
3.08k
stars
738
forks
source link
TypeError: forward() takes 2 positional arguments but 3 were given,flownetc_flow2 = self.flownetc(x)[0].why!!!! #286
Open
zzk1212 opened 3 months ago
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!
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)