TypeError: __init__() got an unexpected keyword argument ‘downsample‘

在这里插入图片描述
报错原因是因为自己把初始化函数__init__()打错了。打成了__int__()。

(ATTE) PS E:\AttnSleep> python train_last.py --fold_id 0 --np_data_dir E:\AttnSleep\prepare_datasets\edf_20_npz AttnSleep( (fc): Sequential( (0): Linear(in_features=30, out_features=1, bias=False) (1): ReLU(inplace=True) (2): Linear(in_features=1, out_features=30, bias=False) (3): Sigmoid() ) ) (downsample): Sequential( (0): Conv1d(128, 30, kernel_size=(1,), stride=(1,), bias=False) (1): BatchNorm1d(30, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True) ) ) ) ) (tce): TCE( (layers): ModuleList( (0-1): 2 x EncoderLayer( (self_attn): MultiHeadedAttention( (convs): ModuleList( (0-2): 3 x CausalConv1d(30, 30, kernel_size=(7,), stride=(1,), padding=(6,)) ) (linear): Linear(in_features=80, out_features=80, bias=True) (dropout): Dropout(p=0.1, inplace=False) ) (feed_forward): PositionwiseFeedForward( (w_1): Linear(in_features=80, out_features=120, bias=True) (w_2): Linear(in_features=120, out_features=80, bias=True) (dropout): Dropout(p=0.1, inplace=False) ) (sublayer_output): ModuleList( (0-1): 2 x SublayerOutput( (norm): LayerNorm() (dropout): Dropout(p=0.1, inplace=False) ) ) (conv): CausalConv1d(30, 30, kernel_size=(7,), stride=(1,), padding=(6,)) ) ) (norm): LayerNorm() ) (fc): Linear(in_features=2400, out_features=5, bias=True) ) Traceback (most recent call last): File "train_last.py", line 91, in <module> main(config, fold_id) File "train_last.py", line 56, in main trainer = Trainer( TypeError: __init__() got an unexpected keyword argument 'metrics' 什么意思 给出的代码运行不了
最新发布
03-09
根据提供的引用内容,出现了TypeError: __init__() got an unexpected keyword argument 'date'和TypeError: __init__() got an unexpected keyword argument ‘encoding’的问题。这两个错误通常是由于使用了不支持的参数导致的。 对于第一个错误,TypeError: __init__() got an unexpected keyword argument 'date',这个错误通常发生在调用某个函数或方法时传递了不支持的参数。要解决这个问题,你需要检查你的代码,确保你传递的参数是正确的,并且与函数或方法的定义相匹配。 对于第二个错误,TypeError: __init__() got an unexpected keyword argument ‘encoding’,这个错误通常发生在使用json模块读取json文件时传递了不支持的参数。要解决这个问题,你需要检查你的代码,确保你传递的参数是正确的,并且与json模块的函数或方法的定义相匹配。 以下是两个示例来演示如何解决这两个错误: 1. 解决TypeError: __init__() got an unexpected keyword argument 'date'错误的示例: ```python class Person: def __init__(self, name): self.name = name person = Person(name='John', date='2021-01-01') # 错误的调用,传递了不支持的参数'date' ``` 在上面的示例中,我们在实例化Person类时传递了一个不支持的参数'date',导致了TypeError: __init__() got an unexpected keyword argument 'date'错误。要解决这个错误,我们需要检查代码并删除不支持的参数'date'。 2. 解决TypeError: __init__() got an unexpected keyword argument ‘encoding’错误的示例: ```python import json with open('data.json', 'r', encoding='utf-8') as file: # 错误的调用,传递了不支持的参数'encoding' data = json.load(file) ``` 在上面的示例中,我们在使用json模块读取json文件时传递了一个不支持的参数'encoding',导致了TypeError: __init__() got an unexpected keyword argument ‘encoding’错误。要解决这个错误,我们需要检查代码并删除不支持的参数'encoding'。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值