keras 实现conv1D卷积

 

import numpy as np
import keras
from keras.models import Sequential
from keras.layers import Dense, Dropout, Flatten, LSTM, Input
from keras.layers import Conv2D, MaxPooling2D, Convolution1D, Activation
from keras.optimizers import SGD
from keras.layers import Input, Dense
from keras.models import Model

model = Sequential()
model.add(Convolution1D(nb_filter=512, filter_length=1, input_shape=(64, 3)))
model.add(Activation('relu'))
model.add(Flatten())
model.add(Dropout(0.4))
model.add(Dense(2048, activation='relu'))
model.add(Dense(1024, activation='relu'))
model.add(Dense(10))
model.add(Activation('softmax'))
model.summary()
_______________________________________________________________
Layer (type)                 Output Shape              Param #   
=================================================================
conv1d_3 (Conv1D)            (None, 64, 512)           2048      
_________________________________________________________________
activation_3 (Activation)    (None, 64, 512)           0         
_________________________________________________________________
flatten_2 (Flatten)          (None, 32768)             0         
_________________________________________________________________
dropout_2 (Dropout)          (None, 32768)             0         
_________________________________________________________________
dense_4 (Dense)              (None, 2048)              67110912  
_________________________________________________________________
dense_5 (Dense)              (None, 1024)              2098176   
_________________________________________________________________
dense_6 (Dense)              (None, 10)                10250     
_________________________________________________________________
activation_4 (Activation)    (None, 10)                0         
=================================================================
Total params: 69,221,386
Trainable params: 69,221,386
Non-trainable params: 0

你可能感兴趣的:(机器学习,python3)