Beispiel #1
0
def get_keras_sub_version():
    try:
        from keras import __version__
        type = int(__version__.split('.')[1])
    except:
        type = 2
    return type
Beispiel #2
0
    def keras_version():
        """ Retrieves the Keras major version.
		"""
        from keras import __version__  # pylint: disable=import-error
        return int(__version__.split('.')[0])
Beispiel #3
0
def get_keras_sub_version():
    from keras import __version__
    type = int(__version__.split('.')[1])
    return type
Beispiel #4
0
from keras import __version__ as keras_version
from keras.models import load_model, model_from_json, model_from_yaml
from keras.layers import Layer
from keras import backend

from dlhub_sdk.models.servables.python import BasePythonServableModel
from dlhub_sdk.utils.types import compose_argument_block

_keras_version_tuple = tuple(int(i) for i in keras_version.split("."))
_summary_limit = 10000


def _detect_backend(output):
    """Add the backend

    Args:
        output (KerasModel): Current description of Keras model, will be modified
    """

    # Determine the name of the object
    my_backend = backend.backend().lower()

    # Add it as a requirement
    output.add_requirement(my_backend, 'detect')


class KerasModel(BasePythonServableModel):
    """Servable based on a Keras Model object.

    Assumes that the model has been saved to an hdf5 file"""
    @classmethod
Beispiel #5
0
	def keras_version():
		""" Retrieves the Keras major version.
		"""
		from keras import __version__			# pylint: disable=import-error
		return int(__version__.split('.')[0])
Beispiel #6
0
    # weight mask constructor functions
    #'construct_efn_weight_mask', 'construct_pfn_weight_mask',

    # network consstructor functions
    #'construct_distributed_dense', 'construct_latent', 'construct_dense', 

    # full model classes
    'EFN', 'PFN'
]

###############################################################################
# Keras 2.2.5 fixes bug in 2.2.4 that affects our usage of the Dot layer
###############################################################################

keras_version_tuple = tuple(map(int, __keras_version__.split('.')))
DOT_AXIS = 0 if keras_version_tuple <= (2, 2, 4) else 1

###############################################################################
# INPUT FUNCTIONS
###############################################################################

def construct_efn_input(input_dim, zs_name=None, phats_name=None):

    # construct input tensors
    zs_input = Input(batch_shape=(None, None), name=zs_name)
    phats_input = Input(batch_shape=(None, None, input_dim), name=phats_name)

    return [zs_input, phats_input]

def construct_pfn_input(input_dim, name=None):