osm_inputs = Input(shape=(osm_max_points, osm_seq_len))
osm_model = LSTM(osm_max_points * 2, activation='relu')(osm_inputs)

concat = concatenate([brt_model, osm_model])
model = Reshape((1, concat.shape[-1].value))(concat)

for layer in range(REPEAT_HIDDEN):
    model = LSTM(LSTM_UNITS, return_sequences=True)(model)
    model = LeakyReLU()(model)
    model = Dense(DENSE_UNITS, activation='relu')(model)

model = LSTM(LSTM_UNITS, activation='relu')(model)  # Flatten
model = Dense(2)(model)
model = Model(inputs=[brt_inputs, osm_inputs], outputs=model)
model.compile(loss=univariate_gaussian_loss, optimizer=OPTIMIZER)
model.summary()

callbacks = [
    TensorBoard(log_dir='./tensorboard_log/' + SIGNATURE, write_graph=False),
    EpochLogger(input_slice=lambda x: x[0:2], target_slice=lambda x: x[2:3], stdout=True),
    EarlyStopping(patience=40, min_delta=0.001)
]

history = model.fit(
    x=[brt_vectors, osm_vectors],
    y=surface_area_vectors,
    epochs=EPOCHS,
    batch_size=BATCH_SIZE,
    validation_split=TRAIN_VALIDATE_SPLIT,
    callbacks=callbacks).history
                activation='relu',
                padding="same",
                kernel_initializer="he_normal"))(model)
model = (UpSampling2D((2, 2)))(model)

model = Conv2D(8,
               kernel_size=(3, 3),
               activation='relu',
               padding="same",
               kernel_initializer="he_normal")(model)
model = (UpSampling2D((2, 2)))(model)

model = Conv2D(1, (3, 3), activation="sigmoid", padding="same")(model)

model = Model(input_image, model)
model.compile(optimizer=Adam(lr=0.0001), loss='mse')
Encoder = Model(input_image, encoder)

## we will have Vto train in batches because the whole thing won't fit in memory
datagen = ImageDataGenerator(featurewise_center=True,
                             rescale=1. / 255,
                             validation_split=0.05)
training = datagen.flow_from_directory(
    "sampled_tiles/training_junk_clusters_removed/",
    class_mode="input",
    batch_size=8,
    target_size=(256, 256),
    color_mode="grayscale")
history = model.fit_generator(training, epochs=20)

with open("models/model_save_10_25_256px_1024_56k_subset.json", 'w') as out: