Skip to content

Commit

Permalink
remove inplace_increment and model_epoch_from_filename
Browse files Browse the repository at this point in the history
  • Loading branch information
JackTemaki committed Mar 28, 2024
1 parent d459571 commit ce269fe
Showing 1 changed file with 0 additions and 42 deletions.
42 changes: 0 additions & 42 deletions returnn/util/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,32 +343,6 @@ def hdf5_strings(handle, name, data):
dset[...] = data


def model_epoch_from_filename(filename):
"""
:param str filename:
:return: epoch number
:rtype: int
"""
# We could check via:
# tf.contrib.framework.python.framework.checkpoint_utils.load_variable()
# once we save that in the model.
# See TFNetwork.Network._create_saver().
# We don't have it in the model, though.
# For now, just parse it from filename.
# If TF, and symlink, resolve until no symlink anymore (e.g. if we symlinked the best epoch).
while True:
tf_meta_fn = "%s.meta" % filename
if os.path.exists(tf_meta_fn) and os.path.islink(tf_meta_fn):
tf_meta_fn_ = os.readlink(tf_meta_fn)
assert tf_meta_fn_.endswith(".meta"), "strange? %s, %s" % (filename, tf_meta_fn)
filename = tf_meta_fn_[: -len(".meta")]
else:
break
m = re.match(".*\\.([0-9]+)", filename)
assert m, "no match for %r" % filename
return int(m.groups()[0])


def deep_update_dict_values(d, key, new_value):
"""
Visits all items in `d`.
Expand Down Expand Up @@ -1055,22 +1029,6 @@ def random_orthogonal(shape, gain=1.0, seed=None):
return gain * q[: shape[0], : shape[1]]


# noinspection PyUnusedLocal
def inplace_increment(x, idx, y):
"""
This basically does `x[idx] += y`.
The difference to the Numpy version is that in case some index is there multiple
times, it will only be incremented once (and it is not specified which one).
See also theano.tensor.subtensor.AdvancedIncSubtensor documentation.
:param numpy.ndarray x:
:param numpy.ndarray idx:
:param numpy.ndarray y:
:rtype: numpy.ndarray
"""
raise NotImplementedError("This feature was removed with dropped Theano support")


def parse_orthography_into_symbols(
orthography, upper_case_special=True, word_based=False, square_brackets_for_specials=True
):
Expand Down

0 comments on commit ce269fe

Please sign in to comment.