123456789101112131415161718192021222324252627282930313233 |
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- # time: 2023/5/8 13:15
- # file: loss.py.py
- # author: David
- # company: shenyang JY
- import tensorflow as tf
- from keras import backend as K
- import keras
- class SouthLoss(keras.losses.Loss):
- def __init__(self, cap):
- """
- 南网新规则损失函数
- :param cap:装机容量
- """
- self.cap = 0.2*cap
- super().__init__()
- def call(self, y_true, y_predict):
- """
- 自动调用
- :param y_true: 标签
- :param y_predict: 预测
- :return: 损失值
- """
- print(type(y_true))
- print("y_shape:", y_true.shape)
- loss = K.square(y_true - y_predict)
- loss = K.mean(loss, axis=-1)
- return loss
|