import numpy
from sklearn.model_selection import GridSearchCV
from keras.models import Sequential
from keras.layers import Dense
from keras.wrappers.scikit_learn import KerasRegressor
from pyDOE import *
from sklearn.model_selection import PredefinedSplit
import time
from src import sampling
from functions import functions

start = time.time()

import airfoil.utility as u
test_dir = r'./test_DIR/'
u.make_sure_path_exists(test_dir)
funObj = functions.Airfoil(5, 0.2, 5e005, test_dir, False)


def create_model(layers=2, units=40, eps=1e-8, lr=1e-5):
    model = Sequential()
    dim = 6
    ## making the model graph, Stacking layers is done by .add():
    model.add(Dense(units=units, input_dim=dim, activation='sigmoid'))
    for i in range(layers - 1):
        model.add(Dense(units=units, activation='sigmoid'))

    model.add(Dense(units=1))

    # optmiser = keras.optimizers.RMSprop(lr=0.001, rho=0.9, epsilon=1e-08, decay=0.0)
    optimizer = keras.optimizers.Adam(lr=lr,
Esempio n. 2
0
    except OSError as exception:
        if exception.errno != errno.EEXIST:
            raise


make_sure_path_exists(path)

for i in range(1):  # how  many times end to end generalisation is done
    i = 0
    series = 0.2 + np.random.rand(5) * 0.2  #2=how many in a series of contexts
    np.savez(path + 'series_{}.npz'.format(i), series)

    start = time.time()

    logdir = path + r's{}/context{}/'.format(i, 0)
    u.make_sure_path_exists(logdir)
    funObj = f.Airfoil(3, series[0], 5e005, logdir, graphics)

    print('Starting iteration number : ', i)
    print('initial number of samples: ', initial_samples)

    model, X, Y = single_run(funObj,
                             initial_samples=initial_samples,
                             model_old=None,
                             X_old=None,
                             Y_old=None)
    model.save(path + r"Airfoil_model_series_{}_context_{}".format(0, 0))
    np.savez(path + r'/Airfoil_XY_series_{}_context_{}'.format(0, 0), X, Y)

    for j in range(1, series.shape[0]):
        logdir = path + r's{}/context{}/'.format(i, j)