moze teraz
This commit is contained in:
parent
aa87018610
commit
13ffa2dade
19
run4.py
19
run4.py
@ -31,16 +31,25 @@ class ANNHyperModel(HyperModel):
|
|||||||
model = tensorflow.keras.Sequential()
|
model = tensorflow.keras.Sequential()
|
||||||
# Tune the number of units in the first Dense layer
|
# Tune the number of units in the first Dense layer
|
||||||
# Choose an optimal value between 32-512
|
# Choose an optimal value between 32-512
|
||||||
hp_units1 = hp.Int('units1', min_value=32, max_value=512, step=32)
|
hp_units1 = hp.Int('units1', min_value=100, max_value=1024, step=32)
|
||||||
hp_units2 = hp.Int('units2', min_value=32, max_value=512, step=32)
|
hp_units2 = hp.Int('units2', min_value=32, max_value=512, step=32)
|
||||||
hp_units3 = hp.Int('units3', min_value=32, max_value=512, step=32)
|
hp_units3 = hp.Int('units3', min_value=32, max_value=512, step=32)
|
||||||
hp_units4 = hp.Int('units4', min_value=32, max_value=512, step=32)
|
hp_units4 = hp.Int('units4', min_value=32, max_value=512, step=32)
|
||||||
hp_units5 = hp.Int('units5', min_value=32, max_value=512, step=32)
|
hp_units5 = hp.Int('units5', min_value=32, max_value=512, step=32)
|
||||||
|
hp_units6 = hp.Int('units6', min_value=32, max_value=512, step=32)
|
||||||
|
# hp_units7 = hp.Int('units7', min_value=32, max_value=512, step=32)
|
||||||
|
# hp_units8 = hp.Int('units8', min_value=32, max_value=512, step=32)
|
||||||
model.add(Dense(units=hp_units1, activation='relu'))
|
model.add(Dense(units=hp_units1, activation='relu'))
|
||||||
model.add(tensorflow.keras.layers.Dense(units=hp_units2, activation='relu'))
|
model.add(tensorflow.keras.layers.Dense(units=hp_units2, activation='relu'))
|
||||||
model.add(tensorflow.keras.layers.Dense(units=hp_units3, activation='relu'))
|
model.add(tensorflow.keras.layers.Dense(units=hp_units3, activation='relu'))
|
||||||
model.add(tensorflow.keras.layers.Dense(units=hp_units4, activation='relu'))
|
model.add(tensorflow.keras.layers.Dense(units=hp_units4, activation='relu'))
|
||||||
model.add(tensorflow.keras.layers.Dense(units=hp_units5, activation='relu'))
|
model.add(
|
||||||
|
tensorflow.keras.layers.Dense(units=hp_units5, activation='relu'))
|
||||||
|
model.add(
|
||||||
|
tensorflow.keras.layers.Dense(units=hp_units6, activation='relu'))
|
||||||
|
# model.add(
|
||||||
|
# tensorflow.keras.layers.Dense(units=hp_units7, activation='relu'))
|
||||||
|
# model.add(tensorflow.keras.layers.Dense(units=hp_units8, activation='relu'))
|
||||||
model.add(Dense(1, kernel_initializer='normal', activation='linear'))
|
model.add(Dense(1, kernel_initializer='normal', activation='linear'))
|
||||||
|
|
||||||
# Tune the learning rate for the optimizer
|
# Tune the learning rate for the optimizer
|
||||||
@ -62,7 +71,7 @@ hypermodel = ANNHyperModel()
|
|||||||
tuner = kt.Hyperband(
|
tuner = kt.Hyperband(
|
||||||
hypermodel,
|
hypermodel,
|
||||||
objective='mean_squared_error',
|
objective='mean_squared_error',
|
||||||
max_epochs=100,
|
max_epochs=80,
|
||||||
factor=3,
|
factor=3,
|
||||||
directory='keras_tuner_dir',
|
directory='keras_tuner_dir',
|
||||||
project_name='keras_tuner_demo2'
|
project_name='keras_tuner_demo2'
|
||||||
@ -70,7 +79,7 @@ tuner = kt.Hyperband(
|
|||||||
#po#ly = PolynomialFeatures(2, interaction_only=True)
|
#po#ly = PolynomialFeatures(2, interaction_only=True)
|
||||||
#x = poly.fit_transform(x)
|
#x = poly.fit_transform(x)
|
||||||
|
|
||||||
tuner.search(x, y, epochs=100)
|
tuner.search(x, y, epochs=80)
|
||||||
|
|
||||||
for h_param in [f"units{i}" for i in range(1,4)] + ['learning_rate']:
|
for h_param in [f"units{i}" for i in range(1,4)] + ['learning_rate']:
|
||||||
print(h_param, tuner.get_best_hyperparameters()[0].get(h_param))
|
print(h_param, tuner.get_best_hyperparameters()[0].get(h_param))
|
||||||
@ -82,7 +91,7 @@ best_model.summary()
|
|||||||
best_model.fit(
|
best_model.fit(
|
||||||
x,
|
x,
|
||||||
y,
|
y,
|
||||||
epochs=100,
|
epochs=80,
|
||||||
batch_size=64
|
batch_size=64
|
||||||
)
|
)
|
||||||
x_test = pd.read_csv("test-A/in.tsv", sep="\t", names=in_columns)
|
x_test = pd.read_csv("test-A/in.tsv", sep="\t", names=in_columns)
|
||||||
|
1440
test-A/out.tsv
1440
test-A/out.tsv
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user