加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
model2.0_try.py 1.27 KB
一键复制 编辑 原始数据 按行查看 历史
peihuanjie 提交于 2021-09-03 13:39 . 项目代码
import os
import keras
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
from keras.models import Model
from keras.layers import *
from matplotlib import pyplot
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
from keras.layers import Dense,Dropout,Activation,Convolution2D,MaxPooling2D,Flatten
from keras.layers import LSTM
def design_model():
# design network
inp=Input(shape=(11,5))
reshape=Reshape((11,5,1))(inp)
conv1=Convolution2D(32,3,3,border_mode='same',init='glorot_uniform')(reshape)
print(conv1)
l1=Activation('relu')(conv1)
conv2=Convolution2D(64,3,3, border_mode='same',)(l1)
l2=Activation('relu')(conv2)
print(l2)
m2=MaxPooling2D(pool_size=(2, 2), border_mode='valid')(l2)
print(m2)
reshape1=Reshape((10,64))(m2)
lstm1=LSTM(input_shape=(10,64),output_dim=30,activation='tanh',return_sequences=False)(reshape1)
dl1=Dropout(0.3)(lstm1)
# den1=Dense(100,activation="relu")(dl1)
den2=Dense(1,activation="relu")(dl1)
model=Model(input=inp,outputs=den2)
model.summary() #打印出模型概况
adam = keras.optimizers.Adam(lr = 0.001, beta_1=0.95, beta_2=0.999,epsilon=1e-08)
model.compile(loss=["mae"], optimizer=adam,metrics=['mape'])
return model
if __name__ == '__main__':
design_model()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化