Skip to content
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
23 changes: 21 additions & 2 deletions gcn/models.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import os

from gcn.layers import *
from gcn.metrics import *

Expand Down Expand Up @@ -93,7 +95,16 @@ def __init__(self, placeholders, input_dim, **kwargs):
self.placeholders = placeholders

self.optimizer = tf.train.AdamOptimizer(learning_rate=FLAGS.learning_rate)


if os.environ.get('TF_ENABLE_AUTO_MIXED_PRECISION', default='0') == '1' or \
('gpu_auto_mixed_precision' in FLAGS and FLAGS.gpu_auto_mixed_precision):
tf_version_list = tf.__version__.split(".")
if int(tf_version_list[0]) < 2:
if int(tf_version_list[1]) < 14:
raise RuntimeError("TensorFlow>=1.14 is required for automatic precision.")
print("=============Enabling GPU Automatic Mixed Precision=============")
self.optimizer = tf.train.experimental.enable_mixed_precision_graph_rewrite(self.optimizer)

self.build()

def _loss(self):
Expand Down Expand Up @@ -140,7 +151,15 @@ def __init__(self, placeholders, input_dim, **kwargs):
self.placeholders = placeholders

self.optimizer = tf.train.AdamOptimizer(learning_rate=FLAGS.learning_rate)

if os.environ.get('TF_ENABLE_AUTO_MIXED_PRECISION', default='0') == '1' or \
('gpu_auto_mixed_precision' in FLAGS and FLAGS.gpu_auto_mixed_precision):
tf_version_list = tf.__version__.split(".")
if int(tf_version_list[0]) < 2:
if int(tf_version_list[1]) < 14:
raise RuntimeError("TensorFlow>=1.14 is required for automatic precision.")
print("=============Enabling GPU Automatic Mixed Precision=============")
self.optimizer = tf.train.experimental.enable_mixed_precision_graph_rewrite(self.optimizer)

self.build()

def _loss(self):
Expand Down
2 changes: 2 additions & 0 deletions gcn/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
flags.DEFINE_float('weight_decay', 5e-4, 'Weight for L2 loss on embedding matrix.')
flags.DEFINE_integer('early_stopping', 10, 'Tolerance for early stopping (# of epochs).')
flags.DEFINE_integer('max_degree', 3, 'Maximum Chebyshev polynomial degree.')
flags.DEFINE_bool("gpu_auto_mixed_precision", default=False,
help="Enabling GPU automatic mixed precision training.")

# Load data
adj, features, y_train, y_val, y_test, train_mask, val_mask, test_mask = load_data(FLAGS.dataset)
Expand Down