Skip to content

Commit

Permalink
Merge pull request #26 from jaeseongyou/patch-6
Browse files Browse the repository at this point in the history
Update applications.md
  • Loading branch information
fuzzythecat authored May 1, 2019
2 parents 96ccf1c + 74d2a87 commit 9fbd4e4
Showing 1 changed file with 75 additions and 75 deletions.
150 changes: 75 additions & 75 deletions sources/applications.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Applications
# 어플리케이션

Keras Applications are deep learning models that are made available alongside pre-trained weights.
These models can be used for prediction, feature extraction, and fine-tuning.
케라스 어플리케이션은 선행학습된 가중치와 함께 사용할 수 있도록 한 딥러닝 모델입니다.
이 모델로 예측, 특성추출, 파인튜닝을 할 수 있습니다.

Weights are downloaded automatically when instantiating a model. They are stored at `~/.keras/models/`.
가중치는 모델을 인스턴스화 할 때 자동으로 다운로드 됩니다. 이는 `~/.keras/models/`에 저장됩니다.

## Available models
## 사용 가능한 모델

### Models for image classification with weights trained on ImageNet:
### ImageNet으로 학습한 가중치를 이용해 이미지 분류를 수행하는 모델:

- [Xception](#xception)
- [VGG16](#vgg16)
Expand All @@ -20,17 +20,17 @@ Weights are downloaded automatically when instantiating a model. They are stored
- [DenseNet](#densenet)
- [NASNet](#nasnet)

All of these architectures are compatible with all the backends (TensorFlow, Theano, and CNTK), and upon instantiation the models will be built according to the image data format set in your Keras configuration file at `~/.keras/keras.json`. For instance, if you have set `image_data_format=channels_last`, then any model loaded from this repository will get built according to the TensorFlow data format convention, "Height-Width-Depth".
위의 아키텍쳐 전부는 모든 백엔드(TensorFlow, Theano, and CNTK)와 호환가능하고, 인스턴스화 시 `~/.keras/keras.json`의 케라스 구성에 세팅된 이미지 데이터 포멧에 따라 모델이 만들어집니다. 예를 들어, 만약 `image_data_format=channels_last`로 세팅이 되어있다면, 이 리포지토리에서 불러온 모든 모델은 "Height-Width-Depth"의 텐서플로우 데이터 포맷 형식에 따라서 만들어집니다.

Note that:
- For `Keras < 2.2.0`, The Xception model is only available for TensorFlow, due to its reliance on `SeparableConvolution` layers.
- For `Keras < 2.1.5`, The MobileNet model is only available for TensorFlow, due to its reliance on `DepthwiseConvolution` layers.
참고로:
- `Keras < 2.2.0`의 경우, Xception 모델은 `SeparableConvolution` 레이어를 이용하기 때문에 TensorFlow로만 사용가능합니다.
- `Keras < 2.1.5`의 경우, MobileNet 모델은 `DepthwiseConvolution` 레이어를 이용하기 때문에 TensorFlow로만 사용가능합니다.

-----

## Usage examples for image classification models
## 이미지 분류 모델의 사용법 예시

### Classify ImageNet classes with ResNet50
### ResNet50을 사용한 ImageNet 클래스 분류

```python
from keras.applications.resnet50 import ResNet50
Expand All @@ -47,13 +47,13 @@ x = np.expand_dims(x, axis=0)
x = preprocess_input(x)

preds = model.predict(x)
# decode the results into a list of tuples (class, description, probability)
# (one such list for each sample in the batch)
# 결과를 튜플의 리스트(클래스, 설명, 확률)로 디코딩합니다
# (배치 내 각 샘플 당 하나의 리스트)
print('Predicted:', decode_predictions(preds, top=3)[0])
# Predicted: [(u'n02504013', u'Indian_elephant', 0.82658225), (u'n01871265', u'tusker', 0.1122357), (u'n02504458', u'African_elephant', 0.061040461)]
# 예측결과: [(u'n02504013', u'Indian_elephant', 0.82658225), (u'n01871265', u'tusker', 0.1122357), (u'n02504458', u'African_elephant', 0.061040461)]
```

### Extract features with VGG16
### VGG16을 사용한 특성추출

```python
from keras.applications.vgg16 import VGG16
Expand All @@ -72,7 +72,7 @@ x = preprocess_input(x)
features = model.predict(x)
```

### Extract features from an arbitrary intermediate layer with VGG19
### VGG19를 사용한 임의의 중간 레이어로부터의 특성추출

```python
from keras.applications.vgg19 import VGG19
Expand All @@ -93,7 +93,7 @@ x = preprocess_input(x)
block4_pool_features = model.predict(x)
```

### Fine-tune InceptionV3 on a new set of classes
### 새로운 클래스에 대한 InceptionV3 파인튜닝

```python
from keras.applications.inception_v3 import InceptionV3
Expand All @@ -102,75 +102,75 @@ from keras.models import Model
from keras.layers import Dense, GlobalAveragePooling2D
from keras import backend as K

# create the base pre-trained model
# 선행학습된 기준모델을 만듭니다
base_model = InceptionV3(weights='imagenet', include_top=False)

# add a global spatial average pooling layer
# 글로벌 공간 평균값 풀링 레이어를 더합니다
x = base_model.output
x = GlobalAveragePooling2D()(x)
# let's add a fully-connected layer
# 완전 연결 레이어를 더합니다
x = Dense(1024, activation='relu')(x)
# and a logistic layer -- let's say we have 200 classes
# 로지스틱 레이어를 더합니다 -- 200가지 클래스가 있다고 가정합니다
predictions = Dense(200, activation='softmax')(x)

# this is the model we will train
# 다음은 학습할 모델입니다
model = Model(inputs=base_model.input, outputs=predictions)

# first: train only the top layers (which were randomly initialized)
# i.e. freeze all convolutional InceptionV3 layers
# 첫째로: (난수로 초기값이 설정된) 가장 상위 레이어들만 학습시킵니다
# 다시 말해서 모든 InceptionV3 콘볼루션 레이어를 고정합니다
for layer in base_model.layers:
layer.trainable = False

# compile the model (should be done *after* setting layers to non-trainable)
# 모델을 컴파일합니다 (*꼭* 레이어를 학습불가 상태로 세팅하고난 *후*에 컴파일합니다)
model.compile(optimizer='rmsprop', loss='categorical_crossentropy')

# train the model on the new data for a few epochs
# 모델을 새로운 데이터에 대해 몇 세대간 학습합니다
model.fit_generator(...)

# at this point, the top layers are well trained and we can start fine-tuning
# convolutional layers from inception V3. We will freeze the bottom N layers
# and train the remaining top layers.
# 이 시점에서 상위 레이어들은 충분히 학습이 되었기에,
# inception V3의 콘볼루션 레이어에 대한 파인튜닝을 시작합니다
# 가장 밑 N개의 레이어를 고정하고 나머지 상위 레이어를 학습시킵니다

# let's visualize layer names and layer indices to see how many layers
# we should freeze:
# 레이어 이름과 레이어 인덱스를 시각화하여
# 얼마나 많은 레이어를 고정시켜야 하는지 확인합니다:
for i, layer in enumerate(base_model.layers):
print(i, layer.name)

# we chose to train the top 2 inception blocks, i.e. we will freeze
# the first 249 layers and unfreeze the rest:
# 가장 상위 2개의 inception 블록을 학습하기로 고릅니다,
# 다시 말하면 첫 249개의 레이어는 고정시키고 나머지는 고정하지 않습니다:
for layer in model.layers[:249]:
layer.trainable = False
for layer in model.layers[249:]:
layer.trainable = True

# we need to recompile the model for these modifications to take effect
# we use SGD with a low learning rate
# 이러한 수정사항이 효과를 내려면 모델을 다시 컴파일해야 합니다
# 낮은 학습 속도로 세팅된 SGD를 사용합니다
from keras.optimizers import SGD
model.compile(optimizer=SGD(lr=0.0001, momentum=0.9), loss='categorical_crossentropy')

# we train our model again (this time fine-tuning the top 2 inception blocks
# alongside the top Dense layers
# 다시 한 번 모델을 학습시킵니다
# (이번엔 상위 2개의 inception 블록을 상위의 밀집 레이어들과 함께 파인튜닝합니다)
model.fit_generator(...)
```


### Build InceptionV3 over a custom input tensor
### 커스텀 인풋 텐서에 대한 InceptionV3 빌드

```python
from keras.applications.inception_v3 import InceptionV3
from keras.layers import Input

# this could also be the output a different Keras model or layer
input_tensor = Input(shape=(224, 224, 3)) # this assumes K.image_data_format() == 'channels_last'
# 다음의 inpu_tensor에 다른 케라스 모델이나 레이어의 아웃풋이 들어갈 수도 있습니다
input_tensor = Input(shape=(224, 224, 3)) # K.image_data_format() == 'channels_last'라고 가정합니다

model = InceptionV3(input_tensor=input_tensor, weights='imagenet', include_top=True)
```

-----

# Documentation for individual models
# 각 모델에 대한 설명서

| Model | Size | Top-1 Accuracy | Top-5 Accuracy | Parameters | Depth |
| 모델 | 사이즈 | 상위-1 정확성 | 상위-5 정확성 | 매개변수 | 깊이 |
| ----- | ----: | --------------: | --------------: | ----------: | -----: |
| [Xception](#xception) | 88 MB | 0.790 | 0.945 | 22,910,480 | 126 |
| [VGG16](#vgg16) | 528 MB | 0.713 | 0.901 | 138,357,544 | 23 |
Expand All @@ -193,9 +193,9 @@ model = InceptionV3(input_tensor=input_tensor, weights='imagenet', include_top=T
| [NASNetMobile](#nasnet) | 23 MB | 0.744 | 0.919 | 5,326,716 | - |
| [NASNetLarge](#nasnet) | 343 MB | 0.825 | 0.960 | 88,949,818 | - |

The top-1 and top-5 accuracy refers to the model's performance on the ImageNet validation dataset.
상위-1과 상위-5 정확성은 ImageNet의 검증 데이터셋에 대한 모델의 성능을 가리킵니다.

Depth refers to the topological depth of the network. This includes activation layers, batch normalization layers etc.
깊이란 네트워크의 토폴로지 깊이를 말합니다. 이는 활성화 레이어, 배치 정규화 레이어 등을 포함합니다.

-----

Expand All @@ -207,52 +207,52 @@ Depth refers to the topological depth of the network. This includes activation l
keras.applications.xception.Xception(include_top=True, weights='imagenet', input_tensor=None, input_shape=None, pooling=None, classes=1000)
```

Xception V1 model, with weights pre-trained on ImageNet.
ImageNet에 대해 가중치가 선행학습된 Xception V1 모델.

On ImageNet, this model gets to a top-1 validation accuracy of 0.790
and a top-5 validation accuracy of 0.945.
이 모델은 ImageNet에 대해서 0.790의 상위-1 검증 정확성을 가집니다.
또한 0.945의 상위-5 검증 정확성을 가집니다.

Note that this model only supports the data format `'channels_last'` (height, width, channels).
이 모델은 `'channels_last'` (height, width, channels) 데이터 포맷만 지원하는 것을 참고하십시오.

The default input size for this model is 299x299.
이 모델의 디폴트 인풋 사이즈는 299x299입니다.

### Arguments
### 인수

- include_top: whether to include the fully-connected layer at the top of the network.
- weights: one of `None` (random initialization) or `'imagenet'` (pre-training on ImageNet).
- include_top: 네트워크의 최상단에 완전 연결 레이어를 넣을지 여부.
- weights: `None` (임의의 초기값 설정) 혹은 `'imagenet'` (ImageNet에 대한 선행 학습) 중 하나.
- input_tensor: optional Keras tensor (i.e. output of `layers.Input()`) to use as image input for the model.
- input_shape: optional shape tuple, only to be specified
if `include_top` is `False` (otherwise the input shape
has to be `(299, 299, 3)`.
It should have exactly 3 inputs channels,
and width and height should be no smaller than 71.
E.g. `(150, 150, 3)` would be one valid value.
- pooling: Optional pooling mode for feature extraction
when `include_top` is `False`.
- `None` means that the output of the model will be
the 4D tensor output of the
last convolutional layer.
- `'avg'` means that global average pooling
will be applied to the output of the
last convolutional layer, and thus
the output of the model will be a 2D tensor.
- `'max'` means that global max pooling will
be applied.
- classes: optional number of classes to classify images
into, only to be specified if `include_top` is `True`, and
if no `weights` argument is specified.

### Returns

A Keras `Model` instance.

### References
- pooling: 특성추출을 위한 선택적 풀링 모드로,
`include_top``False`일 경우 유효합니다.
- `None`은 모델의 아웃풋이
마지박 콘볼루션 레이어의
4D 텐서 아웃풋임을 의미합니다.
- `'avg'`는 글로벌 평균값 풀링이
마지막 콘볼루션 레이어의
아웃풋에 적용되어
모델의 아웃풋은 2D 텐서임을 의미합니다.
- `'max'`는 글로벌 최대값 풀링이
적용됨을 의미합니다.
- classes: 이미지를 분류하기 위한 선택적 클래스 수,
`include_top``True`일 경우,
그리고 `weights` 인수가 특정되지 않은 경우만 특정합니다.

### 반환값

케라스 `Model` 인스턴스.

### 참고

- [Xception: Deep Learning with Depthwise Separable Convolutions](https://arxiv.org/abs/1610.02357)

### License
### 라이센스

These weights are trained by ourselves and are released under the MIT license.
이 가중치는 케라스 측에서 직접 학습시켰으며 MIT 라이센스로 배포되었습니다.


-----
Expand Down

0 comments on commit 9fbd4e4

Please sign in to comment.