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

migrate to tensorflow 2.3 #433

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
34 changes: 31 additions & 3 deletions hparams.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,39 @@
import tensorflow as tf
from text import symbols

class HParams(object):
hparamdict = []
def __init__(self, **hparams):
self.hparamdict = hparams
for k, v in hparams.items():
setattr(self, k, v)
def __repr__(self):
return "HParams(" + repr([(k, v) for k, v in self.hparamdict.items()]) + ")"
def __str__(self):
return ','.join([(k + '=' + str(v)) for k, v in self.hparamdict.items()])
def parse(self, params):
for s in params.split(","):
k, v = s.split("=", 1)
k = k.strip()
t = type(self.hparamdict[k])
if t == bool:
v = v.strip().lower()
if v in ['true', '1']:
v = True
elif v in ['false', '0']:
v = False
else:
raise ValueError(v)
else:
v = t(v)
self.hparamdict[k] = v
setattr(self, k, v)
return self

def create_hparams(hparams_string=None, verbose=False):
"""Create model hyperparameters. Parse nondefault from given string."""

hparams = tf.contrib.training.HParams(
hparams = HParams(
################################
# Experiment Parameters #
################################
Expand Down Expand Up @@ -86,10 +114,10 @@ def create_hparams(hparams_string=None, verbose=False):
)

if hparams_string:
tf.logging.info('Parsing command line hparams: %s', hparams_string)
tf.compat.v1.logging.info('Parsing command line hparams: %s', hparams_string)
hparams.parse(hparams_string)

if verbose:
tf.logging.info('Final parsed hparams: %s', hparams.values())
tf.compat.v1.logging.info('Final parsed hparams: %s', hparams.values())

return hparams
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
matplotlib==2.1.0
tensorflow==1.15.2
tensorflow>=2.3.0
numpy==1.13.3
inflect==0.2.5
librosa==0.6.0
Expand Down