当前位置: 首页>>代码示例>>Python>>正文


Python keras.json方法代码示例

本文整理汇总了Python中keras.json方法的典型用法代码示例。如果您正苦于以下问题:Python keras.json方法的具体用法?Python keras.json怎么用?Python keras.json使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在keras的用法示例。


在下文中一共展示了keras.json方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: import_keras

# 需要导入模块: import keras [as 别名]
# 或者: from keras import json [as 别名]
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):
        try:
            stderr = sys.stderr
            sys.stderr = open(os.devnull, 'w')
            import keras
            sys.stderr = stderr
            return
        except ValueError:
            logging.warning("Unable to import keras. Trying again: {0:d}".format(try_num))
            from time import sleep
            sleep(0.1)
    logging.error("Failed to import keras!") 
开发者ID:vlimant,项目名称:mpi_learn,代码行数:18,代码来源:utils.py

示例2: feature_to_image

# 需要导入模块: import keras [as 别名]
# 或者: from keras import json [as 别名]
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))
    else:
        return backend.reshape(features, (-1, height, width, channels)) 
开发者ID:jhartford,项目名称:DeepIV,代码行数:15,代码来源:architectures.py


注:本文中的keras.json方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。