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

Tensorflow 2.3.0 and Keras 2.4.3 Compatibility #9

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
8 changes: 4 additions & 4 deletions models/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ def minibatch_output_shape(input_shape):


def single_layer_energy(x):
shape = K.get_variable_shape(x)
return K.reshape(K.sum(x, axis=range(1, len(shape))), (-1, 1))
shape = x.shape
return K.reshape(K.sum(x, axis=list(range(1, len(shape)))), (-1, 1))


def single_layer_energy_output_shape(input_shape):
Expand All @@ -98,11 +98,11 @@ def threshold_indicator(x, thresh):


def sparsity_level(x):
_shape = K.get_variable_shape(x)
_shape = x.shape
shape = K.shape(x)
total = K.cast(K.prod(shape[1:]), K.floatx())
return K.reshape(K.sum(
K.cast(x > 0.0, K.floatx()), axis=range(1, len(_shape))
K.cast(x > 0.0, K.floatx()), axis=list(range(1, len(_shape)))
), (-1, 1)) / total


Expand Down
6 changes: 3 additions & 3 deletions models/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def get_parser():
from keras.optimizers import Adam
from keras.utils.generic_utils import Progbar

K.set_image_dim_ordering('tf')
K.image_data_format()

from ops import (minibatch_discriminator, minibatch_output_shape, Dense3D,
calculate_energy, scale, inpainting_attention)
Expand Down Expand Up @@ -160,7 +160,7 @@ def get_parser():
raise exc
nb_classes = len(s.keys())
logger.info('{} particle types found.'.format(nb_classes))
for name, pth in s.iteritems():
for name, pth in s.items():
logger.debug('class {} <= {}'.format(name, pth))

def _load_data(particle, datafile):
Expand Down Expand Up @@ -192,7 +192,7 @@ def _load_data(particle, datafile):

first, second, third, y, energy, sizes = [
np.concatenate(t) for t in [
a for a in zip(*[_load_data(p, f) for p, f in s.iteritems()])
a for a in zip(*[_load_data(p, f) for p, f in s.items()])
]
]

Expand Down