seed 조정 추가
This commit is contained in:
jung-geun
2023-06-30 22:56:25 +09:00
parent 97abf75149
commit 174d68d518
6 changed files with 154 additions and 101 deletions

12
xor.py
View File

@@ -1,19 +1,15 @@
# %%
import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
import tensorflow as tf
tf.random.set_seed(777) # for reproducibility
import numpy as np
np.random.seed(777)
import tensorflow as tf
# from pso_tf import PSO
from pso import Optimizer
from tensorflow import keras
from tensorflow.keras.models import Sequential
from tensorflow.keras import layers
from tensorflow.keras.models import Sequential
print(tf.__version__)
print(tf.config.list_physical_devices())
@@ -40,7 +36,7 @@ x_test, y_test = get_data()
loss = ['mean_squared_error', 'mean_squared_logarithmic_error', 'binary_crossentropy', 'categorical_crossentropy', 'sparse_categorical_crossentropy', 'kullback_leibler_divergence', 'poisson', 'cosine_similarity', 'log_cosh', 'huber_loss', 'mean_absolute_error', 'mean_absolute_percentage_error']
pso_xor = Optimizer(model,
loss=loss[0], n_particles=75, c0=0.35, c1=0.8, w_min=0.6, w_max=1.2, negative_swarm=0.25)
loss=loss[0], n_particles=75, c0=0.35, c1=0.8, w_min=0.6, w_max=1.2, negative_swarm=0.25, mutation_swarm=0.25)
best_score = pso_xor.fit(
x_test, y_test, epochs=200, save=True, save_path="./result/xor", renewal="acc", empirical_balance=False, Dispersion=False, check_point=25)