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
6 changes: 4 additions & 2 deletions lm/modeling.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
import math

import six
import tensorflow as tf
#import tensorflow as tf
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()

from lm import optimization_adafactor
from lm.utils import get_assignment_map_from_checkpoint, get_shape_list, get_attention_mask, gelu, layer_norm, dropout, \
Expand Down Expand Up @@ -84,7 +86,7 @@ def from_dict(cls, json_object):
@classmethod
def from_json_file(cls, json_file):
"""Constructs a `NewsConfig` from a json file of parameters."""
with tf.gfile.GFile(json_file, "r") as reader:
with tf.io.gfile.GFile(json_file, "r") as reader:
text = reader.read()
return cls.from_dict(json.loads(text))

Expand Down
2 changes: 1 addition & 1 deletion lm/optimization_adafactor.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def create_optimizer(loss, init_lr, num_train_steps, num_warmup_steps, use_tpu):
return train_op, train_metrics


class AdaFactorOptimizer(tf.train.Optimizer):
class AdaFactorOptimizer(tf.compat.v1.train.Optimizer):
"""here's the optimizer we'll use"""

def __init__(self,
Expand Down
4 changes: 3 additions & 1 deletion lm/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
import re

import six
import tensorflow as tf
#import tensorflow as tf
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
import numpy as np
from tensorflow.python.lib.io import file_io

Expand Down