Проблема в том, что я нашел только пример двоичной классификации одной метки в TensorFlow 2 do c.
# Scaling by total/2 helps keep the loss to a similar magnitude.
# The sum of the weights of all examples stays the same.
weight_for_0 = (1 / neg)*(total)/2.0
weight_for_1 = (1 / pos)*(total)/2.0
class_weight = {0: weight_for_0, 1: weight_for_1}
print('Weight for class 0: {:.2f}'.format(weight_for_0))
print('Weight for class 1: {:.2f}'.format(weight_for_1))
образец ссылки из do c
Решение, которое я уже пробовал, заключается в использовании списка class_weight, dict class_weight и массива class_weight. Я хотел бы знать, есть ли способ ввести вес класса двоичной классификации с несколькими метками в fit () TensorFlow 2
пример того, что я попробовал
import numpy as np
# list of duct
[{0: 0.474964234620887, 1: 0.525035765379113},{0: 0.48783977110157367, 1: 0.5121602288984263},{0: 0.5135908440629471, 1: 0.4864091559370529},{0: 0.46494992846924177, 1: 0.5350500715307582}]
# dict of dict
{0: {0: 0.474964234620887, 1: 0.525035765379113},
1: {0: 0.48783977110157367, 1: 0.5121602288984263},
2: {0: 0.5135908440629471, 1: 0.4864091559370529},
3: {0: 0.46494992846924177, 1: 0.5350500715307582}}
# array of dict
np.asarray([{0: 0.474964234620887, 1: 0.525035765379113},
{0: 0.48783977110157367, 1: 0.5121602288984263},
{0: 0.5135908440629471, 1: 0.4864091559370529},
{0: 0.46494992846924177, 1: 0.5350500715307582}])