當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。