There's more...

You will come across scenarios where you'll want the output of one model in order to feed it into another model alongside another input. The layer_concatenate() function can be used to do this. Let's define a new input that we will concatenate with the predictions1 output layer we defined in the How to do it section of this recipe and build a model:

# Define new input of the model new_input <- layer_input(shape = c(5), name = "new_input")# Define output layer of new modelmain_output <- layer_concatenate(c(predictions1, new_input)) %>%   layer_dense(units = 64, activation = 'relu') %>%  layer_dense(units = 1, activation = 'sigmoid', name = 'main_output')# We define a multi input and multi output modelmodel <- keras_model( ...

Get Deep Learning with R Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.