2017-05-06 203 views
0

當我運行下面的代碼:如何禁用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") 

如何禁用此警告?

回答

-1

您可以使用環境變量來判斷張量流。從python內部:

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

警告表明您正在使用keras 2.x代碼進行keras 2.x安裝。也許修復它們會更容易,而不是無視。