我正在使用 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,训练就会顺利进行