iT邦幫忙

1

Day37 參加職訓(機器學習與資料分析工程師培訓班),ResNet, RNN

  • 分享至 

  • xImage
  •  

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)

https://ithelp.ithome.com.tw/upload/images/20210819/20139039EvAssSrVhw.png

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)

圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言