# Path: selfsup/multi/methods/base.py
# class Method:
#     def __init__(self, name, batch_size):
#         self.name = name
#         self.batch_size = batch_size
# 
#     def input_size(self):
#         return 0
# 
#     def batch_loader(self):
#         raise NotImplemented("Abstract base class")
# 
#     def build_network(network, y, phase_test):
#         raise NotImplemented("Abstract base class")
# 
#     @property
#     def basenet_settings():
#         return {}
# 
#     def make_path(self, name, ext, iteration):
#         return f'img/{self.name}_{name}_{iteration}.png'


import selfsup
import tensorflow as tf
import os
import deepdish as dd
import numpy as np
from .base import Method
from collections import OrderedDict
        self.logits = z
        self.labels = self._labels

        with tf.variable_scope('primary_loss'):
            if self._loss == 'kl':
                loss_each = tf.nn.sparse_softmax_cross_entropy_with_logits(labels=self._labels, logits=z)
            elif self._loss == 'l2':
                y_onehot = tf.one_hot(self._labels, self._num_classes)
                loss_each = (y_onehot - z)**2
            elif self._loss == 'l1':
                y_onehot = tf.one_hot(self._labels, self._num_classes)
                loss_each = tf.abs(y_onehot - z)
            elif self._loss == 'multilabel':
                y_onehot = tf.one_hot(self._labels, self._num_classes)
                loss_each = tf.nn.sigmoid_cross_entropy_with_logits(labels=y_onehot, logits=z)
            elif self._loss == 'multihinge':
                #loss_each = multi_class_hinge_loss(labels=self._labels, logits=z, n_classes=self._num_classes)
                y_onehot = tf.one_hot(self._labels, self._num_classes)
                loss_each = tf.losses.hinge_loss(labels=y_onehot, logits=z)
            elif self._loss == 'multihinge2':
                #loss_each = multi_class_hinge_loss(labels=self._labels, logits=z, n_classes=self._num_classes)
                y_onehot = tf.one_hot(self._labels, self._num_classes)
                loss_each = tf.losses.hinge_loss(labels=y_onehot, logits=z)
            elif self._loss == 'hinge':
                #z *= 10
                loss_each, a, b = multi_class_hinge_loss(labels=self._labels, logits=z, n_classes=self._num_classes)
                #y_onehot = tf.one_hot(self._labels, self._num_classes)
                #loss_each = tf.losses.hinge_loss(labels=y_onehot, logits=z)
            elif self._loss == 'l2b':
                y_onehot = tf.one_hot(self._labels, self._num_classes)

# Path: selfsup/multi/methods/base.py
# class Method:
#     def __init__(self, name, batch_size):
#         self.name = name
#         self.batch_size = batch_size
# 
#     def input_size(self):
#         return 0
# 
#     def batch_loader(self):
#         raise NotImplemented("Abstract base class")
# 
#     def build_network(network, y, phase_test):
#         raise NotImplemented("Abstract base class")
# 
#     @property
#     def basenet_settings():
#         return {}
# 
#     def make_path(self, name, ext, iteration):
#         return f'img/{self.name}_{name}_{iteration}.png'


# Path: selfsup/multi/methods/supervised.py
import selfsup
import tensorflow as tf
import os
import deepdish as dd
import numpy as np
from .base import Method
from collections import OrderedDict

        self.logits = z
        self.labels = self._labels

        with tf.variable_scope('primary_loss'):
            if self._loss == 'kl':
                loss_each = tf.nn.sparse_softmax_cross_entropy_with_logits(labels=self._labels, logits=z)
            elif self._loss == 'l2':
                y_onehot = tf.one_hot(self._labels, self._num_classes)
                loss_each = (y_onehot - z)**2
            elif self._loss == 'l1':
                y_onehot = tf.one_hot(self._labels, self._num_classes)
                loss_each = tf.abs(y_onehot - z)
            elif self._loss == 'multilabel':
                y_onehot = tf.one_hot(self._labels, self._num_classes)
                loss_each = tf.nn.sigmoid_cross_entropy_with_logits(labels=y_onehot, logits=z)
            elif self._loss == 'multihinge':
                #loss_each = multi_class_hinge_loss(labels=self._labels, logits=z, n_classes=self._num_classes)
                y_onehot = tf.one_hot(self._labels, self._num_classes)
                loss_each = tf.losses.hinge_loss(labels=y_onehot, logits=z)
            elif self._loss == 'multihinge2':
                #loss_each = multi_class_hinge_loss(labels=self._labels, logits=z, n_classes=self._num_classes)
                y_onehot = tf.one_hot(self._labels, self._num_classes)
                loss_each = tf.losses.hinge_loss(labels=y_onehot, logits=z)
            elif self._loss == 'hinge':
                #z *= 10
                loss_each, a, b = multi_class_hinge_loss(labels=self._labels, logits=z, n_classes=self._num_classes)
                #y_onehot = tf.one_hot(self._labels, self._num_classes)
                #loss_each = tf.losses.hinge_loss(labels=y_onehot, logits=z)
            elif self._loss == 'l2b':
                y_onehot = tf.one_hot(self._labels, self._num_classes)

                loss_each = (y_onehot - z)**2 * (y_onehot * (self._num_classes - 1) + 1)