ResNet架構
from tensorflow.keras import Input, Model
from tensorflow.keras.layers import Conv2D, Concatenate, MaxPooling2D
from tensorflow.keras.utils import plot_model
Res_Input = Input(shape=(32,32,3))
Res_Block_Con_Output01 = Conv2D(32, kernel_size=(3,3), activation='relu', padding='SAME')(Res_Input)
Res_Block_Con_Output02 = Conv2D(32, kernel_size=(3,3), activation='relu', padding='SAME')(Res_Block_Con_Output01)
Res_Block_Output = Concatenate()([Res_Input, Res_Block_Con_Output01, Res_Block_Con_Output02])
Res_Model = Model(inputs=Res_Input, outputs=Res_Block_Output)
plot_model(Res_Model, dpi=300, show_shapes=True)
RNN(SimpleRNN)
import numpy as np
Data = np.array([[[0],[1]],[[1],[1]],[[1],[2]]])
Target = np.array([1,2,0])
# One-hot encoding
from tensorflow.keras.utils import to_categorical
X = to_categorical(Data)
y = to_categorical(Target)
# 建構模型
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import SimpleRNN
RNN_Model = Sequential()
RNN_Model.add(SimpleRNN(3, activation='softmax', input_shape=(2,3)))
# 訓練模型
RNN_Model.compile(optimizer='rmsprop', loss='categorical_crossentropy', metrics=['accuracy'])
RNN_Model.fit(X, y, epochs=500)