Sequential model
方法一、
返回原模型(不包含最后一層)的拷貝
new_model = tf.keras.models.Sequential(base_model.layers[:-1])
方法二、
原地刪除原模型的最后一層
base_model._layers.pop()
函數式 API
方法三、
不改動原模型,在采用函數式API構建新模型時,將原模型的倒數第二層的輸出向量拼接至新層
x = base_model.layers[-2].output
方法一、
返回原模型(不包含最后一層)的拷貝
new_model = tf.keras.models.Sequential(base_model.layers[:-1])
方法二、
原地刪除原模型的最后一層
base_model._layers.pop()
方法三、
不改動原模型,在采用函數式API構建新模型時,將原模型的倒數第二層的輸出向量拼接至新層
x = base_model.layers[-2].output
本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。