from gtrain import Model
import numpy as np
import tensorflow as tf


class NetForHypinv(Model):
    """
    Implementaion of the crutial function for the HypINV algorithm.
    Warning: Do not use this class but implement its subclass, for example see FCNetForHypinv
    """
    def __init__(self, weights):
        self.eval_session = None
        self.grad_session = None
        self.initial_x = None
        self.center = None
        self.weights = weights
        self.out_for_eval = None #(going to be filled in build_for_eval method)
        self.boundary_out_for_eval = None
        self.trained_x = None
        self.training_class_index = None
        self.x = None # tf variable for inversion (going to be filled in build method)
        self.x_for_eval = None
        self.out = None
        self.boundary_out = None # list of tf tensorf for each class of softmax class vs others output
        self.loss = None
        self.boundary_loss = None
        self.t = None #target
        self.boundary_t = None
        self.x1 = None # this attribute is used of purposes of modified loss function


    def __del__(self):
        # close arr sessions
        if self.eval_session:
            self.eval_session.close()
        if self.grad_session:
            self.grad_session.close()

    def set_initial_x(self, initial_x):
        # sets starting point for the search of the closest point
        self.initial_x = initial_x

    def set_center(self, center):
        # sets center point
        self.center = center / 
np.linalg.norm(center)