"""Model used to predict water."""

import tflearn
import numpy as np

def normalize_input(features):
    features = features.astype(np.float32)
    return features.multiply(features, 1.0 / 255.0)

def train_model(features, labels, tile_size):
    pass

def create_model(features, labels, tile_size):
    # TODO: Declare 3 a variable as num_channels.
    # From DeepOSM.
    net = tflearn.input_data(shape=[None, tile_size, tile_size, 3])
    net = tflearn.conv2d(net, 64, 12, strides=4, activation='relu')
    net = max_pool_2d(net, 3)

    softmax = tflearn.fully_connected(net, 2, activation='softmax')

    momentum = tflearn.optimizers.Momentum(
        learning_rate=0.005, momentum=0.9,
        lr_decay=0.002, name='Momentum'
    )

    net = tflearn.regression(softmax, optimizer=momentum, loss='categorical_crossentropy')

    return tflearn.DNN(net, tensorboard_verbose=0)


def evaluate_model(model, features, labels):
    pass

@@ -48,26 +48,274 @@
 arn%0A
-import numpy as np
+from tflearn.layers.conv import conv_2d, max_pool_2d%0Aimport numpy as np%0Afrom process_geotiff import read_geotiff, read_bitmap, create_tiles%0Afrom transform_shapefile import create_image, muenster_img, muenster_water, DATA_DIR%0A%0AMODEL_CACHE = DATA_DIR + %22working/logs/%22
 %0A%0Ade
@@ -397,24 +397,18 @@
  return 
-features
+np
 .multipl
@@ -487,46 +487,202 @@
     
-pass%0A%0Adef create_model(features, label
+features = normalize_input(features)%0A    model = create_model(features, tile_size)%0A    print(%22Start training.%22)%0A    model.fit(features, labels) # TODO: Hyperparameters.%0A%0Adef create_model(feature
 s, t
@@ -844,20 +844,13 @@
 t = 
-tflearn.
 conv
+_
 2d(n
@@ -965,17 +965,35 @@
 ed(net, 
-2
+tile_size*tile_size
 , activa
@@ -1284,16 +1284,45 @@
 erbose=0
+, tensorboard_dir=MODEL_CACHE
 )%0A%0A%0Adef 
@@ -1371,8 +1371,825 @@
    pass%0A
+%0Aif __name__ == '__main__':%0A    tile_size = 64%0A    tile_overlap = 0%0A    geotiffs = %5B(muenster_img, %5Bmuenster_water%5D)%5D%0A    features = np.empty((0,tile_size,tile_size,3))%0A    labels = np.empty((0,tile_size,tile_size,1)) # TODO: Check shape%0A    for geotiff, shapefiles in geotiffs:%0A        dataset, bands = read_geotiff(geotiff)%0A        water_img = create_image(dataset, shapefiles, geotiff)%0A        water_img%5Bwater_img == 255%5D = 1%0A        tiled_bands = create_tiles(bands, tile_size, tile_overlap)%0A        tiled_bitmap = create_tiles(water_img, tile_size, tile_overlap)%0A        features = np.concatenate((features, tiled_bands), axis=0)%0A        labels = np.concatenate((labels, tiled_bitmap), axis=0)%0A%0A    labels = np.reshape(labels, (labels.shape%5B0%5D, tile_size*tile_size))%0A    train_model(features, labels, tile_size)%0A

implement working neural net