# for point_sequence in target_triangles] (set_size, max_points, GEO_VECTOR_LEN) = np.array(target_vectors).shape inputs = Input(shape=training_vectors.shape[1:]) model = RepeatVector(max_points)(inputs) model = LSTM(LATENT_SIZE, activation='relu', return_sequences=True)(model) model = Dense(32, activation='relu')(model) model = LSTM(LATENT_SIZE, activation='relu', return_sequences=True)(model) model = Dense(32, activation='relu')(model) model = Dense(17)(model) model = Model(inputs, model) loss = GaussianMixtureLoss( num_points=max_points, num_components=COMPONENTS).geom_gaussian_mixture_loss model.compile(loss=loss, optimizer=OPTIMIZER) model.summary() callbacks = [ TensorBoard(log_dir='./tensorboard_log/' + TIMESTAMP + ' ' + SCRIPT_NAME, write_graph=False), EpochLogger(input_func=lambda x: [ Polygon(np.reshape(x, (6, 2))[0:3]).wkt, Polygon(np.reshape(x, (6, 2))[3:]).wkt ], target_func=lambda x: [GeoVectorizer.decypher(x)], predict_func=lambda x: [ Point(point).wkt for point in GeoVectorizer( gmm_size=COMPONENTS).decypher_gmm_geom(x) ], aggregate_func=lambda x: save_plot(
osm_inputs = Input(shape=(osm_max_points, OSM_INPUT_VECTOR_LEN)) osm_model = LSTM(osm_max_points * 2, activation='relu')(osm_inputs) concat = concatenate([brt_model, osm_model]) model = RepeatVector(target_max_points)(concat) for layer in range(REPEAT_HIDDEN): model = LSTM(LSTM_SIZE, activation='relu', return_sequences=True)(model) model = TimeDistributed(Dense(DENSE_SIZE, activation='relu'))(model) model = Dense(output_seq_length)(model) model = Model(inputs=[brt_inputs, osm_inputs], outputs=model) model.compile( loss=Loss.geom_gaussian_mixture_loss, optimizer=OPTIMIZER) model.summary() # Callbacks callbacks = [ TensorBoard(log_dir='./tensorboard_log/' + TIMESTAMP + ' ' + SCRIPT_NAME, write_graph=False), DecypherAll(gmm_size=GAUSSIAN_MIXTURE_COMPONENTS, plot_dir=PLOT_DIR, input_slice=lambda x: x[:2], target_slice=lambda x: x[2:3], stdout=False), EarlyStopping(patience=40, min_delta=1) ] history = model.fit(