|
|
|
"""
|
|
|
|
import pickle
|
|
|
|
|
|
|
|
# if db[column].count() > 0 :
|
|
|
|
value= args['value']
|
|
|
|
inputs = args['inputs']
|
|
|
|
name = args['name']
|
|
|
|
labels = None if 'labels' not in args else args['labels']
|
|
|
|
n_labels= None if 'n_labels' not in args else args['n_labels']
|
|
|
|
shift = [0] if self.__class__.__name__.lower() == 'generator' else [1] #-- not sure what this is doing
|
|
|
|
mean, var = tf.nn.moments(inputs, shift, keep_dims=True)
|
|
|
|
shape = inputs.shape[1].value
|
|
|
|
for i, dim in enumerate(self.G_STRUCTURE[:-1]):
|
|
|
|
kernel = self.get.variables(name='W_' + str(i), shape=[tmp_dim, dim])
|
|
|
|
h1 = self.normalize(inputs=tf.matmul(x, kernel),shift=0, name='cbn' + str(i), labels=label, n_labels=self.NUM_LABELS)
|
|
|
|
h2 = tf.nn.relu(h1)
|
|
|
|
x = x + h2
|
|
|
|
tmp_dim = dim
|
|
|
|
i = len(self.G_STRUCTURE) - 1
|
|
|
|
#
|
|
|
|
# This seems to be an extra hidden layer:
|
|
|
|
# It's goal is to map continuous values to discrete values (pre-trained to do this)
|
|
|
|
kernel = self.get.variables(name='W_' + str(i), shape=[tmp_dim, self.G_STRUCTURE[-1]])
|
|
|
|
h1 = self.normalize(inputs=tf.matmul(x, kernel), name='cbn' + str(i),
|
|
|
|
labels=label, n_labels=self.NUM_LABELS)
|
|
|
|
h2 = tf.nn.tanh(h1)
|
|
|
|
x = x + h2
|
|
|
|
# This seems to be the output layer
|
|
|
|
#
|
|
|
|
kernel = self.get.variables(name='W_' + str(i+1), shape=[self.Z_DIM, self.X_SPACE_SIZE])
|
|
|
|
bias = self.get.variables(name='b_' + str(i+1), shape=[self.X_SPACE_SIZE])
|
|
|
|
x = tf.nn.sigmoid(tf.add(tf.matmul(x, kernel), bias))
|
|
|
|
return x
|
|
|
|
return w_distance, loss
|
|
|
|
# @TODO: Ziqi needs to explain what's going on here
|
|
|
|
# labels_placeholder = None
|
|
|
|
# suffix = "-".join(self.ATTRIBUTES['synthetic']) if isinstance(self.ATTRIBUTES['synthetic'],list) else self.ATTRIBUTES['synthetic']
|
|
|
|
# if 'no_value' in args and args['no_value'] not in ['na','','NA'] :
|
|
|
|
tf.compat.v1.reset_default_graph()
|
|
|
|
# # If the generator had a reductive effect we should be able to get random values from either :
|
|
|
|
# # - The space of outliers
|
|
|
|
# # - existing values for smaller spaces that have suffered over training
|
|
|
|
# #
|
|
|
|
|
|
|
|
# N = ii.sum()
|
|
|
|
# missing_values = self.MISSING_VALUES if self.MISSING_VALUES else self.values
|
|
|
|
# missing = np.random.choice(missing_values,N)
|
|
|
|
# # missing = []
|
|
|
|
# #
|
|
|
|
# # @TODO:
|
|
|
|
# # Log the findings here in terms of ratio, missing, candidate count
|
|
|
|
# # print ([np.max(ratio),len(missing),len(found),i])
|
|
|
|
# i = np.where(ii == 0)[0]
|
|
|
|
# return df.to_dict(orient='list')
|
|
|
|
|