Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

converting to tf2 #425

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions python/deprecated/eval_sgf.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,12 @@ def play(pla,loc):

print(board.to_string())

saver = tf.train.Saver(
saver = tf.compat.v1.train.Saver(
max_to_keep = 10000,
save_relative_paths = True,
)

with tf.Session() as session:
with tf.compat.v1.Session() as session:

if not debug:
saver.restore(session, modelpath)
Expand Down
12 changes: 6 additions & 6 deletions python/deprecated/export_model.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def log(s):
model = Model(model_config)

total_parameters = 0
for variable in tf.trainable_variables():
for variable in tf.compat.v1.trainable_variables():
shape = variable.get_shape()
variable_parameters = 1
for dim in shape:
Expand All @@ -63,17 +63,17 @@ def log(s):

print("Testing", flush=True)

saver = tf.train.Saver(
saver = tf.compat.v1.train.Saver(
max_to_keep = 10000,
save_relative_paths = True,
)

#Some tensorflow options
#tfconfig = tf.ConfigProto(log_device_placement=False,device_count={'GPU': 0})
tfconfig = tf.ConfigProto(log_device_placement=False)
tfconfig = tf.compat.v1.ConfigProto(log_device_placement=False)
#tfconfig.gpu_options.allow_growth = True
#tfconfig.gpu_options.per_process_gpu_memory_fraction = 0.4
with tf.Session(config=tfconfig) as session:
with tf.compat.v1.Session(config=tfconfig) as session:
saver.restore(session, model_file)

sys.stdout.flush()
Expand All @@ -85,7 +85,7 @@ def log(s):
sys.stderr.flush()

if not for_cuda:
tf.train.write_graph(session.graph_def,export_dir,filename_prefix + ".graph.pb")
tf.io.write_graph(session.graph_def,export_dir,filename_prefix + ".graph.pb")
savepath = export_dir + "/" + filename_prefix
saver.save(session, savepath + ".weights")
with open(savepath + ".config.json","w") as f:
Expand All @@ -112,7 +112,7 @@ def writeln(s):
writeln(model.max_board_size) #y
writeln(model.num_input_features)

variables = dict((variable.name,variable) for variable in tf.global_variables())
variables = dict((variable.name,variable) for variable in tf.compat.v1.global_variables())
def get_weights(name):
return np.array(variables[name+":0"].eval())

Expand Down
8 changes: 4 additions & 4 deletions python/deprecated/find_poses.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def log(s):
policy_probs_output = tf.nn.softmax(model.policy_output)

total_parameters = 0
for variable in tf.trainable_variables():
for variable in tf.compat.v1.trainable_variables():
shape = variable.get_shape()
variable_parameters = 1
for dim in shape:
Expand Down Expand Up @@ -94,17 +94,17 @@ def log(s):
sgfhash_start = next_moves_start + next_moves_len
sgfhash_len = 8

saver = tf.train.Saver(
saver = tf.compat.v1.train.Saver(
max_to_keep = 10000,
save_relative_paths = True,
)

#Some tensorflow options
#tfconfig = tf.ConfigProto(log_device_placement=False,device_count={'GPU': 0})
tfconfig = tf.ConfigProto(log_device_placement=False)
tfconfig = tf.compat.v1.ConfigProto(log_device_placement=False)
#tfconfig.gpu_options.allow_growth = True
#tfconfig.gpu_options.per_process_gpu_memory_fraction = 0.4
with tf.Session(config=tfconfig) as session:
with tf.compat.v1.Session(config=tfconfig) as session:
saver.restore(session, model_file)

log("Began session, loaded model")
Expand Down
10 changes: 5 additions & 5 deletions python/deprecated/mixmodels.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def volume(variable):

variables = {}
total_parameters = 0
for variable in tf.global_variables():
for variable in tf.compat.v1.global_variables():
variable_parameters = volume(variable)
total_parameters += variable_parameters
variables[variable.name] = variable
Expand All @@ -59,16 +59,16 @@ def volume(variable):

print("Testing", flush=True)

saver = tf.train.Saver(
saver = tf.compat.v1.train.Saver(
max_to_keep = 10000,
save_relative_paths = True,
)

count = 0
accum_weights = {}

tfconfig = tf.ConfigProto(log_device_placement=False)
with tf.Session(config=tfconfig) as session:
tfconfig = tf.compat.v1.ConfigProto(log_device_placement=False)
with tf.compat.v1.Session(config=tfconfig) as session:

for model_file in model_files:
saver.restore(session, model_file)
Expand All @@ -91,7 +91,7 @@ def run(fetches):

assign_ops = dict([(name,variables[name].assign(accum_weights[name])) for name in accum_weights])

with tf.Session(config=tfconfig) as session:
with tf.compat.v1.Session(config=tfconfig) as session:
session.run(assign_ops)
print("Saving to " + output_file)
saver.save(session, output_file)
Expand Down
Loading