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

added option to use tensorflow.keras #123

Merged
merged 2 commits into from
Apr 14, 2022
Merged
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
15 changes: 14 additions & 1 deletion pumpp/feature/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,10 @@ def layers(self, api='keras'):
field keys.
'''

if api == 'keras':
if api in ('k', 'keras'):
return self.layers_keras()
elif api in ('tf.keras', 'tensorflow.keras', 'tfk'):
return self.layers_tfkeras()
elif api in ('tf', 'tensorflow'):
return self.layers_tensorflow()
else:
Expand All @@ -144,6 +146,17 @@ def layers_keras(self):

return L

def layers_tfkeras(self):
from tensorflow.keras.layers import Input

L = dict()
for key in self.fields:
L[key] = Input(name=key,
shape=self.fields[key].shape,
dtype=np.dtype(self.fields[key].dtype).name)

return L

def n_frames(self, duration):
'''Get the number of frames for a given duration

Expand Down
4 changes: 4 additions & 0 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,10 @@ def test_pump_layers(sr, hop_length):
for d1, d2 in zip(L1[k].shape, L2[k].shape):
assert str(d1) == str(d2)

# test other input layers
P.layers('tf.keras')
P.layers('tf')


def test_pump_str(sr, hop_length):

Expand Down