mirror of
https://github.com/jung-geun/PSO.git
synced 2025-12-20 04:50:45 +09:00
23-07-09
dev container 조정
This commit is contained in:
@@ -16,7 +16,9 @@
|
|||||||
"donjayamanne.python-extension-pack",
|
"donjayamanne.python-extension-pack",
|
||||||
"tht13.python",
|
"tht13.python",
|
||||||
"esbenp.prettier-vscode",
|
"esbenp.prettier-vscode",
|
||||||
"ms-python.black-formatter"
|
"ms-python.black-formatter",
|
||||||
|
"github.vscode-github-actions",
|
||||||
|
"eamodio.gitlens"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
@@ -1,6 +1,5 @@
|
|||||||
{
|
{
|
||||||
"[python]": {
|
"[python]": {
|
||||||
"editor.defaultFormatter": "ms-python.black-formatter"
|
"editor.defaultFormatter": "ms-python.black-formatter"
|
||||||
},
|
}
|
||||||
"python.formatting.provider": "none"
|
|
||||||
}
|
}
|
||||||
8
mnist.py
8
mnist.py
@@ -50,7 +50,7 @@ def make_model():
|
|||||||
|
|
||||||
# %%
|
# %%
|
||||||
model = make_model()
|
model = make_model()
|
||||||
x_train, y_train, x_test, y_test = get_data()
|
x_train, y_train = get_data_test()
|
||||||
|
|
||||||
loss = [
|
loss = [
|
||||||
"mse",
|
"mse",
|
||||||
@@ -73,9 +73,9 @@ if __name__ == "__main__":
|
|||||||
loss=loss[2],
|
loss=loss[2],
|
||||||
n_particles=100,
|
n_particles=100,
|
||||||
c0=0.35,
|
c0=0.35,
|
||||||
c1=0.8,
|
c1=0.7,
|
||||||
w_min=0.4,
|
w_min=0.5,
|
||||||
w_max=1.1,
|
w_max=0.9,
|
||||||
negative_swarm=0.2,
|
negative_swarm=0.2,
|
||||||
mutation_swarm=0.1,
|
mutation_swarm=0.1,
|
||||||
)
|
)
|
||||||
|
|||||||
19
mnist_tf.py
19
mnist_tf.py
@@ -43,21 +43,14 @@ def get_data_test():
|
|||||||
def make_model():
|
def make_model():
|
||||||
model = Sequential()
|
model = Sequential()
|
||||||
model.add(
|
model.add(
|
||||||
Conv2D(
|
Conv2D(32, kernel_size=(5, 5), activation="relu", input_shape=(28, 28, 1))
|
||||||
32,
|
|
||||||
kernel_size=(5, 5),
|
|
||||||
strides=(1, 1),
|
|
||||||
padding="same",
|
|
||||||
activation="relu",
|
|
||||||
input_shape=(28, 28, 1),
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
model.add(MaxPooling2D(pool_size=(2, 2), strides=(2, 2)))
|
model.add(MaxPooling2D(pool_size=(3, 3)))
|
||||||
model.add(Conv2D(64, kernel_size=(2, 2), activation="relu", padding="same"))
|
model.add(Conv2D(64, kernel_size=(3, 3), activation="relu"))
|
||||||
model.add(MaxPooling2D(pool_size=(2, 2)))
|
model.add(MaxPooling2D(pool_size=(2, 2)))
|
||||||
model.add(Dropout(0.25))
|
model.add(Dropout(0.25))
|
||||||
model.add(Flatten())
|
model.add(Flatten())
|
||||||
model.add(Dense(1000, activation="relu"))
|
model.add(Dense(128, activation="relu"))
|
||||||
model.add(Dense(10, activation="softmax"))
|
model.add(Dense(10, activation="softmax"))
|
||||||
|
|
||||||
return model
|
return model
|
||||||
@@ -66,7 +59,9 @@ def make_model():
|
|||||||
model = make_model()
|
model = make_model()
|
||||||
x_train, y_train, x_test, y_test = get_data()
|
x_train, y_train, x_test, y_test = get_data()
|
||||||
|
|
||||||
model.compile(optimizer="adam", loss="sparse_categorical_crossentropy", metrics=["accuracy"])
|
model.compile(
|
||||||
|
optimizer="sgd", loss="sparse_categorical_crossentropy", metrics=["accuracy"]
|
||||||
|
)
|
||||||
|
|
||||||
print("Training model...")
|
print("Training model...")
|
||||||
model.fit(x_train, y_train, epochs=1000, batch_size=128, verbose=1)
|
model.fit(x_train, y_train, epochs=1000, batch_size=128, verbose=1)
|
||||||
|
|||||||
@@ -379,8 +379,10 @@ class Optimizer:
|
|||||||
score[0] = np.inf
|
score[0] = np.inf
|
||||||
if score[1] == None:
|
if score[1] == None:
|
||||||
score[1] = 0
|
score[1] = 0
|
||||||
|
|
||||||
loss = loss + score[0]
|
loss = loss + score[0]
|
||||||
acc = acc + score[1]
|
acc = acc + score[1]
|
||||||
|
|
||||||
if score[0] < min_loss:
|
if score[0] < min_loss:
|
||||||
min_loss = score[0]
|
min_loss = score[0]
|
||||||
if score[0] > max_loss:
|
if score[0] > max_loss:
|
||||||
|
|||||||
Reference in New Issue
Block a user