Python keras.json() Examples

The following are 2 code examples for showing how to use keras.json(). These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.

You may check out the related API usage on the sidebar.

You may also want to check out all available functions/classes of the module keras , or try the search function .

Example 1
Project: mpi_learn   Author: vlimant   File:    License: GNU General Public License v3.0 6 votes vote down vote up
def import_keras(tries=10):
    """There is an issue when multiple processes import Keras simultaneously --
        the file .keras/keras.json is sometimes not read correctly.  
        as a workaround, just try several times to import keras."""
    for try_num in range(tries):
            stderr = sys.stderr
            sys.stderr = open(os.devnull, 'w')
            import keras
            sys.stderr = stderr
        except ValueError:
            logging.warning("Unable to import keras. Trying again: {0:d}".format(try_num))
            from time import sleep
    logging.error("Failed to import keras!") 
Example 2
Project: DeepIV   Author: jhartford   File:    License: MIT License 5 votes vote down vote up
def feature_to_image(features, height=28, width=28, channels=1, backend=K):
    Reshape a flattened image to the input format for convolutions.

    Can be used either as a Keras operation using the default backend or
    with numpy by using the argument backend=np

    Conforms to the image data format setting defined in ~/.keras/keras.json
    if K.image_data_format() == "channels_first":
        return backend.reshape(features, (-1, channels, height, width))
        return backend.reshape(features, (-1, height, width, channels))