-
Notifications
You must be signed in to change notification settings - Fork 3
/
misc.py
26 lines (22 loc) · 829 Bytes
/
misc.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/env python3
#Auxiliary function for KerBS
import tensorflow as tf
def debug_print(content, verbose=False, tff=True):
if verbose:
if tff:
tf.logging.info(content)
else:
print('debug:'+content)
def advanced_add_to_collections(name, value, name_value):
name_name=name+'_name'
if value not in tf.get_collection(name) and name_value not in tf.get_collection(name_name):
tf.add_to_collections(name, value)
tf.add_to_collections(name_name, name_value)
return True
return False
def advanced_get_collection(name, name_value):
name_name=name+'_name'
value_dict=dict(zip(tf.get_collection(name_name), tf.get_collection(name)))
if name_value in value_dict:
return value_dict[name_value]
return None