當前位置: 首頁>>代碼示例>>Python>>正文


Python vis_utils.plot_model方法代碼示例

本文整理匯總了Python中keras.utils.vis_utils.plot_model方法的典型用法代碼示例。如果您正苦於以下問題:Python vis_utils.plot_model方法的具體用法?Python vis_utils.plot_model怎麽用?Python vis_utils.plot_model使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在keras.utils.vis_utils的用法示例。


在下文中一共展示了vis_utils.plot_model方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: predict

# 需要導入模塊: from keras.utils import vis_utils [as 別名]
# 或者: from keras.utils.vis_utils import plot_model [as 別名]
def predict(options, img_read_path, img_write_path):
    # Read image
    content = process_image(img_read_path, -1, -1, resize=False)
    ori_height = content.shape[1]
    ori_width = content.shape[2]

    # Pad image
    content = get_padding(content)
    height = content.shape[1]
    width = content.shape[2]

    # Get eval model
    eval_model = get_evaluate_model(width, height)
    eval_model.load_weights(options['weights_read_path'])

    # If flag is set, print model summary and generate model description
    if options["plot_model"]:
        eval_model.summary()
        plot_model(eval_model, to_file='model.png')

    # Generate output and save image
    res = eval_model.predict([content])
    output = deprocess_image(res[0], width, height)
    output = remove_padding(output, ori_height, ori_width)
    imwrite(img_write_path, output) 
開發者ID:overflocat,項目名稱:fast-neural-style-keras,代碼行數:27,代碼來源:helper_functions.py

示例2: train

# 需要導入模塊: from keras.utils import vis_utils [as 別名]
# 或者: from keras.utils.vis_utils import plot_model [as 別名]
def train(self, dataset, epoches):
        sample_count, generator = createDataGenerater(dataset)
        history = self.model.fit_generator(
            generator(),
            steps_per_epoch=sample_count,
            epochs=epoches,
            verbose=1
        )

        save_dir = join_path(config.model_dir, self.model_type + '-' + str(config.classes) + 'class-' + str(self.epoch) + 'epoch-' + datetime.now().strftime("%Y%m%d%H%M%S"))
        if not os.path.exists(save_dir):
            os.mkdir(save_dir)
        logger.info('model path: %s', save_dir)
        with open(os.path.join(save_dir, self.MODEL_FILE_NAME), mode='w', encoding='utf-8') as model_file:
            model_file.write(self.model.to_yaml())
        vis_utils.plot_model(self.model, to_file=os.path.join(save_dir, self.VISUALIZED_MODEL_FILE_NAME), show_shapes=True)
        self.model.save_weights(os.path.join(save_dir, self.WEIGHTS_FILE_NAME))
        self.model.save(os.path.join(save_dir, self.ALL_IN_MODEL_FILE_NAME)) 
開發者ID:mrm-xiefan,項目名稱:lunania-ai,代碼行數:20,代碼來源:fcn.py

示例3: save_model_figure

# 需要導入模塊: from keras.utils import vis_utils [as 別名]
# 或者: from keras.utils.vis_utils import plot_model [as 別名]
def save_model_figure(model, file_path='/.model.eps'):
    vis_utils.plot_model(model, file_path, show_shapes=True, show_layer_names=True) 
開發者ID:CMU-CREATE-Lab,項目名稱:deep-smoke-machine,代碼行數:4,代碼來源:keras_utils.py

示例4: model_summary

# 需要導入模塊: from keras.utils import vis_utils [as 別名]
# 或者: from keras.utils.vis_utils import plot_model [as 別名]
def model_summary():
    X_left = Input((dim, dim, bin_vec_dim))
    X_right = Input((dim, dim, bin_vec_dim))
    predictions = classification(X_left, X_right)
    model = Model(inputs=[X_left, X_right], outputs=predictions)
    model.compile(optimizer=K.optimizers.adam(lr=0.0005),
                  loss=K.losses.binary_crossentropy,
                  metrics=['accuracy'])
    
    # plot_model(model, to_file='./result/plot/whole_model.png', show_shapes=True) 
開發者ID:parasol-aser,項目名稱:deepsim,代碼行數:12,代碼來源:classification_bigbench_keras.py

示例5: test_plot_model

# 需要導入模塊: from keras.utils import vis_utils [as 別名]
# 或者: from keras.utils.vis_utils import plot_model [as 別名]
def test_plot_model():
    model = Sequential()
    model.add(Conv2D(filters=2, kernel_size=(2, 3), input_shape=(3, 5, 5), name='conv'))
    model.add(Flatten(name='flat'))
    model.add(Dense(5, name='dense1'))
    vis_utils.plot_model(model, to_file='model1.png', show_layer_names=False)
    os.remove('model1.png')

    model = Sequential()
    model.add(LSTM(16, return_sequences=True, input_shape=(2, 3), name='lstm'))
    model.add(TimeDistributed(Dense(5, name='dense2')))
    vis_utils.plot_model(model, to_file='model2.png', show_shapes=True)
    os.remove('model2.png') 
開發者ID:hello-sea,項目名稱:DeepLearning_Wavelet-LSTM,代碼行數:15,代碼來源:vis_utils_test.py

示例6: plot_model

# 需要導入模塊: from keras.utils import vis_utils [as 別名]
# 或者: from keras.utils.vis_utils import plot_model [as 別名]
def plot_model(model, file_path='model.eps'):
    vis_utils.plot_model(model, file_path, show_shapes=True, show_layer_names=True) 
開發者ID:noureldien,項目名稱:videograph,代碼行數:4,代碼來源:keras_utils.py

示例7: MobileNetv2

# 需要導入模塊: from keras.utils import vis_utils [as 別名]
# 或者: from keras.utils.vis_utils import plot_model [as 別名]
def MobileNetv2(input_shape, k, alpha=1.0):
    """MobileNetv2
    This function defines a MobileNetv2 architectures.

    # Arguments
        input_shape: An integer or tuple/list of 3 integers, shape
            of input tensor.
        k: Integer, number of classes.
        alpha: Integer, width multiplier, better in [0.35, 0.50, 0.75, 1.0, 1.3, 1.4].

    # Returns
        MobileNetv2 model.
    """
    inputs = Input(shape=input_shape)

    first_filters = _make_divisible(32 * alpha, 8)
    x = _conv_block(inputs, first_filters, (3, 3), strides=(2, 2))

    x = _inverted_residual_block(x, 16, (3, 3), t=1, alpha=alpha, strides=1, n=1)
    x = _inverted_residual_block(x, 24, (3, 3), t=6, alpha=alpha, strides=2, n=2)
    x = _inverted_residual_block(x, 32, (3, 3), t=6, alpha=alpha, strides=2, n=3)
    x = _inverted_residual_block(x, 64, (3, 3), t=6, alpha=alpha, strides=2, n=4)
    x = _inverted_residual_block(x, 96, (3, 3), t=6, alpha=alpha, strides=1, n=3)
    x = _inverted_residual_block(x, 160, (3, 3), t=6, alpha=alpha, strides=2, n=3)
    x = _inverted_residual_block(x, 320, (3, 3), t=6, alpha=alpha, strides=1, n=1)

    if alpha > 1.0:
        last_filters = _make_divisible(1280 * alpha, 8)
    else:
        last_filters = 1280

    x = _conv_block(x, last_filters, (1, 1), strides=(1, 1))
    x = GlobalAveragePooling2D()(x)
    x = Reshape((1, 1, last_filters))(x)
    x = Dropout(0.3, name='Dropout')(x)
    x = Conv2D(k, (1, 1), padding='same')(x)

    x = Activation('softmax', name='softmax')(x)
    output = Reshape((k,))(x)

    model = Model(inputs, output)
    # plot_model(model, to_file='images/MobileNetv2.png', show_shapes=True)

    return model 
開發者ID:xiaochus,項目名稱:MobileNetV2,代碼行數:46,代碼來源:mobilenet_v2.py


注:本文中的keras.utils.vis_utils.plot_model方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。