mirror of
https://github.com/jung-geun/PSO.git
synced 2025-12-19 20:44:39 +09:00
23-06-11
env.yaml 추가 - 가상환경 생성하기 간편하게 하기 위해 추가
This commit is contained in:
17
env.yaml
Normal file
17
env.yaml
Normal file
@@ -0,0 +1,17 @@
|
||||
name: pso
|
||||
channels:
|
||||
- conda-forge
|
||||
- nvidia/label/cuda-11.8.0
|
||||
- defaults
|
||||
dependencies:
|
||||
- cuda-nvcc=11.8.89=0
|
||||
- cudatoolkit=11.8.0=h6a678d5_0
|
||||
- matplotlib=3.7.1=py39h06a4308_1
|
||||
- pandas=1.5.3=py39h417a72b_0
|
||||
- pip=23.0.1=py39h06a4308_0
|
||||
- python=3.9.16=h7a1cb2a_2
|
||||
- pip:
|
||||
- numpy==1.23.5
|
||||
- nvidia-cudnn-cu11==8.6.0.163
|
||||
- tensorflow==2.12.0
|
||||
- tqdm==4.65.1.dev3+g5587f0d
|
||||
2
mnist.py
2
mnist.py
@@ -70,7 +70,7 @@ if __name__ == "__main__":
|
||||
pso_mnist = Optimizer(
|
||||
model,
|
||||
loss=loss[0],
|
||||
n_particles=200,
|
||||
n_particles=50,
|
||||
c0=0.35,
|
||||
c1=0.8,
|
||||
w_min=0.7,
|
||||
|
||||
12
readme.md
12
readme.md
@@ -25,6 +25,12 @@ $$
|
||||
|
||||
위치를 가장 최적값으로 변경하면 지역 최적값에서 벗어나지 못합니다. 따라서 전역 최적값을 찾을 수 없습니다.
|
||||
|
||||
# 초기 세팅
|
||||
|
||||
``` shell
|
||||
conda env create -f env.yaml
|
||||
```
|
||||
|
||||
# 현재 진행 상황
|
||||
|
||||
## 1. PSO 알고리즘 구현
|
||||
@@ -77,6 +83,7 @@ pso 알고리즘을 이용하여 오차역전파 함수를 최적화 하는 방
|
||||
## 3. PSO 알고리즘을 이용하여 풀이한 문제들의 정확도
|
||||
|
||||
### 1. xor 문제
|
||||
|
||||
``` python
|
||||
loss = 'mean_squared_error'
|
||||
|
||||
@@ -103,10 +110,12 @@ pso 알고리즘을 이용하여 오차역전파 함수를 최적화 하는 방
|
||||
check_point=25
|
||||
)
|
||||
```
|
||||
|
||||
위의 파라미터 기준 40 세대 이후부터 정확도가 100%가 나오는 것을 확인하였습니다
|
||||

|
||||
|
||||
2. iris 문제
|
||||
|
||||
``` python
|
||||
loss = 'categorical_crossentropy'
|
||||
|
||||
@@ -133,10 +142,12 @@ best_score = pso_iris.fit(
|
||||
check_point=25
|
||||
)
|
||||
```
|
||||
|
||||
위의 파라미터 기준 2 세대에 94%의 정확도를, 7 세대에 96%, 106 세대에 99.16%의 정확도를 보였습니다
|
||||

|
||||
|
||||
3. mnist 문제
|
||||
|
||||
``` python
|
||||
loss = 'mean_squared_error'
|
||||
|
||||
@@ -163,6 +174,7 @@ best_score = pso_mnist.fit(
|
||||
check_point=25
|
||||
)
|
||||
```
|
||||
|
||||
위의 파라미터 기준 현재 정확도 38%를 보이고 있습니다
|
||||

|
||||
|
||||
|
||||
40
test.ipynb
40
test.ipynb
@@ -391,13 +391,51 @@
|
||||
"print(y_test)\n",
|
||||
"print(model.evaluate(x_test,y_test))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"2023-06-11 14:01:31.378413: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.\n",
|
||||
"To enable the following instructions: AVX2 FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"TensorFlow version: 2.12.0\n",
|
||||
"Linked TRT ver: (8, 4, 3)\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import tensorflow as tf\n",
|
||||
"print(\"TensorFlow version:\", tf.__version__)\n",
|
||||
"import tensorflow.compiler as tf_cc\n",
|
||||
"import tensorrt as trt\n",
|
||||
"linked_trt_ver=tf_cc.tf2tensorrt._pywrap_py_utils.get_linked_tensorrt_version()\n",
|
||||
"print(f\"Linked TRT ver: {linked_trt_ver}\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "pso",
|
||||
"language": "python",
|
||||
"name": "pso"
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
|
||||
Reference in New Issue
Block a user