第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

當(dāng)我嘗試將列表傳遞給我的類屬性時發(fā)生錯誤

當(dāng)我嘗試將列表傳遞給我的類屬性時發(fā)生錯誤

翻閱古今 2023-01-04 16:19:00
我正在嘗試使用類方法將列表傳遞給我的類屬性:class BASE_MODEL(object):    def __init__(self, train_data, train_labels, val_data, val_labels):        self.train_data, self.train_labels, self.val_data, self.val_labels = \            train_data, train_labels, val_data, val_labels    @classmethod    def list_to_data(cls, data_list):        train_data, train_labels, val_data, val_labels = data_list        data = cls(train_data, train_labels, val_data, val_labels)        return dataclass Fine_Tune_Model(BASE_MODEL):    def __init__(self, fine_tune_at=None):        super(BASE_MODEL, self).__init__()        self.fine_tune_at = fine_tune_atfine_tune_model = Fine_Tune_Model.list_to_data(data_lsit)這對超類很好用。但是,當(dāng)我嘗試將相同的函數(shù)傳遞給子類時,會發(fā)生錯誤:Traceback (most recent call last):  File "E:/Studium/Thesis/Fine_Tuning.py", line 138, in <module>    main()  File "E:/Studium/Thesis/Fine_Tuning.py", line 133, in main    fine_tune_model = Fine_Tune_Model.list_to_data(create_data.split_data(3000, 200))  File "E:\Studium\Thesis\Train.py", line 32, in list_to_data    data = cls(train_data, train_labels, val_data, val_labels)TypeError: __init__() takes from 1 to 2 positional arguments but 5 were givenProcess finished with exit code 1是因為我的子類中多了一個參數(shù)“fine_tune_at”嗎?如果是這樣,我該如何避免這個問題?
查看完整描述

1 回答

?
MMTTMM

TA貢獻(xiàn)1869條經(jīng)驗 獲得超4個贊

我發(fā)現(xiàn)問題出在哪里:


class BASE_MODEL(object):

    def __init__(self, train_data, train_labels, val_data, val_labels):

        self.train_data, self.train_labels, self.val_data, self.val_labels = \

            train_data, train_labels, val_data, val_labels


    @classmethod

    def list_to_data(cls, data_list):

        train_data, train_labels, val_data, val_labels = data_list

        data = cls(train_data, train_labels, val_data, val_labels)

        return data


class Fine_Tune_Model(BASE_MODEL):

    def __init__(self, train_data, train_labels, val_data, val_labels):

        super(Fine_Tune_Model, self).__init__(train_data, train_labels, val_data, val_labels)

        self.fine_tune_at = fine_tune_at


fine_tune_model = Fine_Tune_Model.list_to_data(data_lsit)

我沒有正確繼承超類中的屬性。


查看完整回答
反對 回復(fù) 2023-01-04
  • 1 回答
  • 0 關(guān)注
  • 101 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號