8wDlpd.png
8wDFp9.png
8wDEOx.png
8wDMfH.png
8wDKte.png

Model.fit 与 class_weight 给出关键错误,因为关键不在类权重中

aceraven777 2月前

17 0

我正在使用 class_weight 进行 model.fit`careful_bias_history = model.fit(train_features,y_train,batch_size=BATCH_SIZE,epochs=1,validation_data=(test_features,y_test), class_weight={0: 0.

我正在使用 class_weight 进行 model.fit

`careful_bias_history = model.fit(train_features,y_train,batch_size=BATCH_SIZE,epochs=1,validation_data=(test_features,y_test), class_weight={0: 0.5004904334283419, 1: 510.25318066157763})`

我收到密钥错误

File /opt/conda/lib/python3.10/site-packages/keras/src/utils/traceback_utils.py:122, in filter_traceback.<locals>.error_handler(*args, **kwargs)
119     filtered_tb = _process_traceback_frames(e.__traceback__)
120     # To get the full stack trace, call:
121     # `keras.config.disable_traceback_filtering()`
122     raise e.with_traceback(filtered_tb) from None
123 finally:
124     del filtered_tb

File /opt/conda/lib/python3.10/site-packages/pandas/core/series.py:1121, in Series.__getitem__(self, key)
1118     return self._values[key]
1120 elif key_is_scalar:
1121     return self._get_value(key)
1123 # Convert generator to list before going through hashable part
1124 # (We will iterate through the generator there to check for slices)
1125 if is_iterator(key):

File /opt/conda/lib/python3.10/site-packages/pandas/core/series.py:1237, in Series._get_value(self, label, takeable)
1234     return self._values[label]
1236 # Similar to Index.get_value, but we do not fall back to positional
1237 loc = self.index.get_loc(label)
1239 if is_integer(loc):
1240     return self._values[loc]

File /opt/conda/lib/python3.10/site-packages/pandas/core/indexes/base.py:3812, in Index.get_loc(self, key)
3807     if isinstance(casted_key, slice) or (
3808         isinstance(casted_key, abc.Iterable)
3809         and any(isinstance(x, slice) for x in casted_key)
3810     ):
3811         raise InvalidIndexError(key)
3812     raise KeyError(key) from err
3813 except TypeError:
3814     # If we have a listlike key, _check_indexing_error will raise
3815     #  InvalidIndexError. Otherwise we fall through and re-raise
3816     #  the TypeError.
3817     self._check_indexing_error(key)

KeyError: 8

今天密钥是 8,但昨天是 4,不知道它从哪里选择这个密钥

如果我删除 Class_weight,训练就会顺利进行

帖子版权声明 1、本帖标题:Model.fit 与 class_weight 给出关键错误,因为关键不在类权重中
    本站网址:http://xjnalaquan.com/
2、本网站的资源部分来源于网络,如有侵权,请联系站长进行删除处理。
3、会员发帖仅代表会员个人观点,并不代表本站赞同其观点和对其真实性负责。
4、本站一律禁止以任何方式发布或转载任何违法的相关信息,访客发现请向站长举报
5、站长邮箱:yeweds@126.com 除非注明,本帖由aceraven777在本站《tensorflow》版块原创发布, 转载请注明出处!
最新回复 (0)
返回
作者最近主题: