假设我已经在R中训练了我的Keras模型;例如说:
model<-keras_model_sequential() model %>% layer_dense(units=5,activation = "relu",input_shape = c(4))%>% layer_dense(units=Height,activation = "relu",input_shape = c(4)) %>% model %>% layer_dense(units=1)
一旦经过培训,是否可以在保持其他所有内容不变的情况下删除最后一层?
答案 0 :(得分:1)
如果先分别定义图层,则可以使用相同的图层创建新模型:
model <- keras_model_sequential()
firstLayer <- layer_dense(units=5,activation = "relu",input_shape = c(4))
secondLayer <- layer_dense(units=Height,activation = "relu",input_shape = c(4))
model %>% firstLayer %>%
secondLayer %>%
layer_dense(units=1)
新模型:
model2 <- keras_model_sequential()
model2 %>% firstLayer %>%
secondLayer