<jupyter_start><jupyter_text>Quick Intro to Keras Functional API  Preamble: All models (layers) are callables ```pythonfrom keras.layers import Input, Densefrom keras.models import Model this returns a tensorinputs = Input(shape=(784,)) a layer instance is callable on a tensor, and returns a tensorx = Dense(64, activation='relu')(inputs)x = Dense(64, activation='relu')(x)predictions = Dense(10, activation='softmax')(x) this creates a model that includes the Input layer and three Dense layersmodel = Model(input=inputs, output=predictions)model.compile(optimizer='rmsprop',              loss='categorical_crossentropy',              metrics=['accuracy'])model.fit(data, labels)   starts training```  Multi-Input Networks  Keras Merge Layer Here's a good use case for the functional API: models with multiple inputs and outputs. The functional API makes it easy to manipulate a large number of intertwined datastreams.Let's consider the following model.  ```pythonfrom keras.layers import Dense, Inputfrom keras.models import Modelfrom keras.layers.merge import concatenateleft_input = Input(shape=(784, ), name='left_input')left_branch = Dense(32, input_dim=784, name='left_branch')(left_input)right_input = Input(shape=(784,), name='right_input')right_branch = Dense(32, input_dim=784, name='right_branch')(right_input)x = concatenate([left_branch, right_branch])predictions = Dense(10, activation='softmax', name='main_output')(x)model = Model(inputs=[left_input, right_input], outputs=predictions)``` Resulting Model will look like the following network:  Such a two-branch model can then be trained via e.g.: ```pythonmodel.compile(optimizer='rmsprop', loss='categorical_crossentropy', metrics=['accuracy'])model.fit([input_data_1, input_data_2], targets)   we pass one data array per model input```  Try yourself  Step 1: Get Data - MNIST<jupyter_code># let's load MNIST data as we did in the exercise on MNIST with FC Nets
# %load ../solutions/sol_52.py<jupyter_output><empty_output><jupyter_text>Step 2: Create the Multi-Input Network<jupyter_code>## try yourself

## `evaluate` the model on test data<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1092436974789916, 'fraction_numerical': 0.015406162464985995, 'mean_word_length': 6.7644927536231885, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '541342', 'license': 'MIT', 'n_tokens_mistral': 659, 'n_tokens_neox': 628, 'n_words': 198, 'path': 'day03/additional materials/5.2 Multi-Modal Networks.ipynb', 'repo_name': 'MeRajat/Deep-Learning-Boot-Camp', 'size': '2142'}