env.yaml 추가 - 가상환경 생성하기 간편하게 하기 위해 추가
This commit is contained in:
jung-geun
2023-06-11 14:45:01 +00:00
parent 1662d58f05
commit 34729e9b33
6 changed files with 75 additions and 8 deletions

17
env.yaml Normal file
View 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

View File

@@ -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,

File diff suppressed because one or more lines are too long

View File

@@ -25,13 +25,19 @@ $$
위치를 가장 최적값으로 변경하면 지역 최적값에서 벗어나지 못합니다. 따라서 전역 최적값을 찾을 수 없습니다.
# 초기 세팅
``` shell
conda env create -f env.yaml
```
# 현재 진행 상황
## 1. PSO 알고리즘 구현
### 파일 구조
```plain text
``` plain text
|-- metacode # pso 기본 코드
| |-- pso_bp.py # 오차역전파 함수를 최적화하는 PSO 알고리즘 구현 - 성능이 99% 이상으로 나오나 목적과 다름
| |-- pso_meta.py # 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%가 나오는 것을 확인하였습니다
![xor](./history_plt/xor_sigmoid_2_acc_40.png)
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%의 정확도를 보였습니다
![iris](./history_plt/iris_relu_acc_200.png)
3. mnist 문제
``` python
loss = 'mean_squared_error'
@@ -163,6 +174,7 @@ best_score = pso_mnist.fit(
check_point=25
)
```
위의 파라미터 기준 현재 정확도 38%를 보이고 있습니다
![mnist](./history_plt/mnist_cnn_acc.png)

View File

@@ -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": {

2
xor.py
View File

@@ -21,7 +21,7 @@ print(tf.__version__)
print(tf.config.list_physical_devices())
def get_data():
x = np.array([[0, 0], [0, 1], [1, 0], [1, 1]])
x = np.array([[0, 0], [0, 1], [1, 0], [1, 1]])
y = np.array([[0], [1], [1], [0]])
return x, y