|
|
|
"""
|
|
|
|
from data.params import SYS_ARGS
|
|
|
|
self.BATCHSIZE_PER_GPU = PROPOSED_BATCH_PER_GPU
|
|
|
|
#
|
|
|
|
if os.path.exists(_name) :
|
|
|
|
attr = json.loads((open(_name)).read())
|
|
|
|
for key in attr :
|
|
|
|
value = attr[key]
|
|
|
|
# f.close()
|
|
|
|
|
|
|
|
for _info in [{"name":os.sep.join([self.out_dir,'meta-'+suffix+'.json']),"data":_object},{"name":os.sep.join([self.out_dir,'epochs.json']),"data":self.logs['epochs'] if 'epochs' in self.logs else []}] :
|
|
|
|
f = open(_info['name'],'w')
|
|
|
|
f.write(json.dumps(_info['data']))
|
|
|
|
f.close()
|
|
|
|
n_labels number of labels default None
|
|
|
|
"""
|
|
|
|
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
|
|
|
|
for g, _ in grad_and_vars:
|
|
|
|
tmp_dim = self.Z_DIM if 'dim' not in args else args['dim']
|
|
|
|
label = args['label']
|
|
|
|
loss = w_distance + 10 * gradient_penalty + sum(all_regs)
|
|
|
|
#tf.add_to_collection('dlosses', loss)
|
|
|
|
tf.compat.v1.add_to_collection('dlosses', loss)
|
|
|
|
|
|
|
|
return w_distance, loss
|
|
|
|
|
|
|
|
print(format_str % (epoch, -w_sum/(self.STEPS_PER_EPOCH*2), duration))
|
|
|
|
# print (dir (w_distance))
|
|
|
|
|
|
|
|
# This would allow the learnt model to be portable to another system
|
|
|
|
|
|
|
|
|
|
|
|
def _apply(self,**args):
|
|
|
|
if labels :
|
|
|
|
# continue
|
|
|
|
# self.logger.write({"module":"gan-generate","action":"generate","input":info})
|
|
|
|
# self.logger.write({"module":"gan-generate","action":"compile.io","input":info})
|