如何禁用keras警告? [英] How to disable keras warnings?

查看:816
本文介绍了如何禁用keras警告?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我运行以下代码时:

init = "he_uniform"

inp = Input(shape=(1800, 1))
norm1 = BatchNormalization(mode=0)(inp)
conv1 = Convolution1D(16, 5,  border_mode='same', init=init, activation="relu")(norm1)
pool1 = MaxPooling1D(pool_size=3)(conv1)
norm2 = BatchNormalization(mode=0)(pool1)
flat1 = Flatten()(norm2)
dens1 = Dense(128, init=init, activation="relu")(flat1)
#norm3 = BatchNormalization(mode=0)(dens1)
output = Dense(2, init=init, activation="softmax")(dens1)
from keras.models import *
model = Model(input=[inp], output=output)

我有警告:

root/miniconda/envs/jupyterhub_py3/lib/python3.4/site-packages/ipykernel/__main__.py:4: UserWarning: Update your `BatchNormalization` call to the Keras 2 API: `BatchNormalization()`
/root/miniconda/envs/jupyterhub_py3/lib/python3.4/site-packages/ipykernel/__main__.py:5: UserWarning: Update your `Conv1D` call to the Keras 2 API: `Conv1D(16, 5, activation="relu", kernel_initializer="he_uniform", padding="same")`
/root/miniconda/envs/jupyterhub_py3/lib/python3.4/site-packages/ipykernel/__main__.py:7: UserWarning: Update your `BatchNormalization` call to the Keras 2 API: `BatchNormalization()`
/root/miniconda/envs/jupyterhub_py3/lib/python3.4/site-packages/ipykernel/__main__.py:9: UserWarning: Update your `Dense` call to the Keras 2 API: `Dense(128, activation="relu", kernel_initializer="he_uniform")`

以下方法无济于事.

with warnings.catch_warnings():
    warnings.simplefilter("ignore")

如何禁用此警告?

推荐答案

您可以使用环境变量告诉tensorflow.从python内部:

You can tell tensorflow using environment variables. From within python:

import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'

警告表明您在安装keras 2.x时使用了keras 1.x代码.也许更容易修复它们,而不是忽略它们.

The warnings indicate you are using keras 1.x code with a keras 2.x installation. Maybe it would be easier to fix them, instead of ignoring.

这篇关于如何禁用keras警告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆