renom_img.api.classification ¶
-
class
VGG11
( class_map=None , imsize=(224 , 224) , load_pretrained_weight=False , train_whole_network=False ) ¶ -
VGG11モデル
パラメータ: - class_map ( list , dict ) -- クラス名の配列
- imsize ( int , tuple ) -- 入力画像サイズ
- load_pretrained_weight ( bool , str ) -- 事前学習済みの重みを使うかどうかを指定します。VGG11には現在事前学習済みの重みが用意されていないため、Falseに設定するか、ユーザが事前に学習した重みのファイル名に設定する必要があります。
- train_whole_network ( bool ) -- モデル全体を学習させる場合はTrue、そうでなければFalse
例
>>> from renom_img.api.classification.vgg import VGG11 >>> >>> class_map = ["dog", "cat"] >>> model = VGG11(class_map, imsize=(224,224), load_pretrained_weight=False, train_whole_network=True)
注釈
VGG11には現在事前学習済みの重みが用意されていないため、
load_pretrained_weight
をFalse
に設定する必要があります。ImageNetで学習された重みを初期値として利用するには、VGG16、VGG19またはResNet/ResNeXt系のReNomモデルを利用してください。参照
Karen Simonyan, Andrew ZissermanVery Deep Convolutional Networks for Large-Scale Image Recognition
-
build_data
( ) ¶ -
この関数はVGG11用の入力データと出力データを作成します。
戻り値: 入力データと出力データを作成する関数を返します。 戻り値の型: (function) 例
>>> builder = model.build_data() # This will return function. >>> x, y = builder(image_path_list, annotation_list) >>> z = model(x) >>> loss = model.loss(z, y)
-
fit
( train_img_path_list=None , train_annotation_list=None , valid_img_path_list=None , valid_annotation_list=None , epoch=136 , batch_size=64 , optimizer=None , augmentation=None , callback_end_epoch=None ) ¶ -
この関数は与えられたデータを元に学習を行います。
パラメータ: - train_img_path_list ( list ) -- クラス名の配列
- train_annotation_list ( list ) -- クラス名の配列
- valid_img_path_list ( list ) -- バリデーションの画像のパスのリスト
- valid_annotation_list ( list ) -- バリデーション用のアノテーションのリスト
- epoch ( int ) -- 学習時のエポック数
- batch_size ( int ) -- バッチサイズ
- augmentation ( Augmentation ) -- Augmentationオブジェクト
- callback_end_epoch ( function ) -- 与えらえた関数は各エポックの終了時に呼ばれます。
戻り値: 学習誤差のリストとバリデーション誤差のリスト
戻り値の型: (tuple)
例
>>> train_img_path_list, train_annot_list = ... # Define train data >>> valid_img_path_list, valid_annot_list = ... # Define validation data >>> class_map = ... # Define class map >>> model = VGG11(class_map) # Specify any algorithm provided by ReNomIMG API here >>> model.fit( ... # Feeds image and annotation data ... train_img_path_list, ... train_annot_list, ... valid_img_path_list, ... valid_annot_list, ... epoch=8, ... batch_size=8) >>>
以下の引数はcallback_end_epochに指定された関数に渡されます。
- epoch (int) - 現在のエポック数
- model (Model) - モデルオブジェクト
- avg_train_loss_list (list) - 各エポックの平均学習誤差のリスト
- avg_train_loss_list (list) - 各エポックの平均バリデーション誤差のリスト
-
forward
( x ) ¶ -
順伝播を実行します。この関数は__call__メソッドにより呼ぶことができます。
パラメータ: x ( ndarray , Node ) -- VGG11への入力 戻り値: VGG11の生の出力を返します。 戻り値の型: (Node) 例
>>> import numpy as np >>> x = np.random.rand(1, 3, 224, 224) >>> >>> class_map = ["dog", "cat"] >>> model = VGG11(class_map) >>> >>> y = model.forward(x) # Forward propagation. >>> y = model(x) # Same as above result.
-
loss
( x , y ) ¶ -
VGG11アルゴリズムの誤差関数
パラメータ: - x ( ndarray , Node ) -- モデルの出力
- y ( ndarray , Node ) -- ターゲット配列
戻り値: xとy間の誤差
戻り値の型: (Node)
例
>>> builder = model.build_data() # This will return a builder function. >>> x, y = builder(image_path_list, annotation_list) >>> z = model(x) >>> loss = model.loss(z, y)
-
predict
( img_list , batch_size=1 , return_scores=False ) ¶ -
予測を実行します。引数には画像の配列、画像のパスのリストもしくは画像のパスが可能です。
パラメータ: - img_list ( ndarray , list , string ) -- 画像の配列、画像のパスのリストもしくは画像のパス
- batch_size ( int ) -- 入力画像データの処理に使うバッチサイズ
- return_scores ( bool ) -- 全クラスに対する推論結果のスコア値を返すかどうかのフラグ。デフォルトはFalse。
戻り値: 各画像に対する推論結果を返します。return_scoresフラグがTrueであれば、全クラスに対する推論スコア値も返します。
戻り値の型: (array)
-
preprocess
( x ) ¶ -
与えられた配列に対して、前処理を実行します。
パラメータ: x ( ndarray , Node ) -- 前処理用の画像の配列
-
regularize
( ) ¶ -
誤差関数のL2正則化項
例
>>> x = numpy.random.rand(1, 3, 224, 224) # Input image >>> y = ... # Ground-truth label >>> >>> class_map = ['cat', 'dog'] >>> model = VGG11(class_map) >>> >>> z = model(x) # Forward propagation >>> loss = model.loss(z, y) # Loss calculation >>> reg_loss = loss + model.regularize() # Add weight decay term.
-
class
VGG16
( class_map=None , imsize=(224 , 224) , load_pretrained_weight=False , train_whole_network=False ) ¶ -
VGG16モデル
もし引数load_pretrained_weightがTrueなら、事前学習済みの重みがダウンロードされます。事前学習の重みはILSVRC2012を使って学習しています.
パラメータ: - class_map ( list , dict ) -- クラス名の配列
- imsize ( int or tuple ) -- 入力画像サイズ
- load_pretrained_weight ( bool , str ) -- Trueならば、事前学習済みの重みがカレントディレクトリにダウンロードされます。文字列が与えられた場合は、重みはその名前で保存されます。
- train_whole_network ( bool ) -- モデル全体を学習させる場合はTrue、そうでなければFalse
例
>>> from renom_img.api.classification.vgg import VGG16 >>> >>> class_map = ["dog", "cat"] >>> model = VGG16(class_map, imsize=(224,224), load_pretrained_weight=True, train_whole_network=True)
注釈
事前学習のデータセットは1000クラスのため、もし引数num_classが1000でなかった場合は最後のDense層はリセットされます。
参照
Karen Simonyan, Andrew ZissermanVery Deep Convolutional Networks for Large-Scale Image Recognition
-
build_data
( ) ¶ -
この関数はVGG16用の入力データとターゲットデータを作成する関数を返します。
戻り値: 入力データと出力データを作成する関数を返します。 戻り値の型: (function) 例
>>> builder = model.build_data() # This will return function. >>> x, y = builder(image_path_list, annotation_list) >>> z = model(x) >>> loss = model.loss(z, y)
-
fit
( train_img_path_list=None , train_annotation_list=None , valid_img_path_list=None , valid_annotation_list=None , epoch=136 , batch_size=64 , optimizer=None , augmentation=None , callback_end_epoch=None ) ¶ -
この関数は与えられたデータを元に学習を行います。
パラメータ: - train_img_path_list ( list ) -- クラス名の配列
- train_annotation_list ( list ) -- クラス名の配列
- valid_img_path_list ( list ) -- バリデーションの画像のパスのリスト
- valid_annotation_list ( list ) -- バリデーション用のアノテーションのリスト
- epoch ( int ) -- 学習時のエポック数
- batch_size ( int ) -- バッチサイズ
- augmentation ( Augmentation ) -- Augmentationオブジェクト
- callback_end_epoch ( function ) -- 与えらえた関数は各エポックの終了時に呼ばれます。
戻り値: 学習誤差のリストとバリデーション誤差のリスト
戻り値の型: (tuple)
例
>>> train_img_path_list, train_annot_list = ... # Define train data >>> valid_img_path_list, valid_annot_list = ... # Define validation data >>> class_map = ... # Define class map >>> model = VGG16(class_map) # Specify any algorithm provided by ReNomIMG API here >>> model.fit( ... # Feeds image and annotation data ... train_img_path_list, ... train_annot_list, ... valid_img_path_list, ... valid_annot_list, ... epoch=8, ... batch_size=8) >>>
以下の引数はcallback_end_epochに指定された関数に渡されます。
- epoch (int) - 現在のエポック数
- model (Model) - モデルオブジェクト
- avg_train_loss_list (list) - 各エポックの平均学習誤差のリスト
- avg_train_loss_list (list) - 各エポックの平均バリデーション誤差のリスト
-
forward
( x ) ¶ -
順伝播を実行します。この関数は__call__メソッドにより呼ぶことができます。
パラメータ: x ( ndarray , Node ) -- VGG16への入力 戻り値: VGG16への生の出力を返します。 戻り値の型: (Node) 例
>>> import numpy as np >>> x = np.random.rand(1, 3, 224, 224) >>> >>> class_map = ["dog", "cat"] >>> model = VGG16(class_map) >>> >>> y = model.forward(x) # Forward propagation. >>> y = model(x) # Same as above result.
-
loss
( x , y ) ¶ -
VGG16アルゴリズムの誤差関数
パラメータ: - x ( ndarray , Node ) -- モデルの出力
- y ( ndarray , Node ) -- ターゲット配列
戻り値: xとy間の誤差
戻り値の型: (Node)
例
>>> builder = model.build_data() # This will return a builder function. >>> x, y = builder(image_path_list, annotation_list) >>> z = model(x) >>> loss = model.loss(z, y)
-
predict
( img_list , batch_size=1 , return_scores=False ) ¶ -
予測を実行します。引数には画像の配列、画像のパスのリストもしくは画像のパスが可能です。
パラメータ: - img_list ( ndarray , list , string ) -- 画像の配列、画像のパスのリストもしくは画像のパス
- batch_size ( int ) -- 入力画像データの処理に使うバッチサイズ
- return_scores ( bool ) -- 全クラスに対する推論結果のスコア値を返すかどうかのフラグ。デフォルトはFalse。
戻り値: 各画像に対する推論結果を返します。return_scoresフラグがTrueであれば、全クラスに対する推論スコア値も返します。
戻り値の型: (array)
-
preprocess
( x ) ¶ -
与えられた配列に対して、前処理を実行します。
パラメータ: x ( ndarray , Node ) -- 前処理用の画像の配列
-
regularize
( ) ¶ -
誤差関数のL2正則化項
例
>>> x = numpy.random.rand(1, 3, 224, 224) # Input image >>> y = ... # Ground-truth label >>> >>> class_map = ['cat', 'dog'] >>> model = VGG16(class_map) >>> >>> z = model(x) # Forward propagation >>> loss = model.loss(z, y) # Loss calculation >>> reg_loss = loss + model.regularize() # Add weight decay term.
-
class
VGG19
( class_map=None , imsize=(224 , 224) , load_pretrained_weight=False , train_whole_network=False ) ¶ -
VGG19モデル
もし引数load_pretrained_weightがTrueなら、事前学習済みの重みがダウンロードされます。事前学習の重みはILSVRC2012を使って学習しています.
パラメータ: - class_map ( list , dict ) -- クラス名の配列
- imsize ( int , tuple ) -- 入力画像サイズ
- load_pretrained_weight ( bool , str ) -- Trueならば、事前学習済みの重みがカレントディレクトリにダウンロードされます。文字列が与えられた場合は、重みはその名前で保存されます。
- train_whole_network ( bool ) -- モデル全体を学習させる場合はTrue、そうでなければFalse
例
>>> from renom_img.api.classification.vgg import VGG19 >>> >>> class_map = ["dog", "cat"] >>> model = VGG19(class_map, imsize=(224,224), load_pretrained_weight=True, train_whole_network=True)
注釈
事前学習のデータセットは1000クラスのため、もし引数num_classが1000でなかった場合は最後のDense層はリセットされます。
参照
Karen Simonyan, Andrew ZissermanVery Deep Convolutional Networks for Large-Scale Image Recognition
-
build_data
( ) ¶ -
この関数はVGG19用の入力データとターゲットデータを作成する関数を返します。
戻り値: 入力データと出力データを作成する関数を返します。 戻り値の型: (function) 例
>>> builder = model.build_data() # This will return function. >>> x, y = builder(image_path_list, annotation_list) >>> z = model(x) >>> loss = model.loss(z, y)
-
fit
( train_img_path_list=None , train_annotation_list=None , valid_img_path_list=None , valid_annotation_list=None , epoch=136 , batch_size=64 , optimizer=None , augmentation=None , callback_end_epoch=None ) ¶ -
この関数は与えられたデータを元に学習を行います。
パラメータ: - train_img_path_list ( list ) -- クラス名の配列
- train_annotation_list ( list ) -- クラス名の配列
- valid_img_path_list ( list ) -- バリデーションの画像のパスのリスト
- valid_annotation_list ( list ) -- バリデーション用のアノテーションのリスト
- epoch ( int ) -- 学習時のエポック数
- batch_size ( int ) -- バッチサイズ
- augmentation ( Augmentation ) -- Augmentationオブジェクト
- callback_end_epoch ( function ) -- 与えらえた関数は各エポックの終了時に呼ばれます。
戻り値: 学習誤差のリストとバリデーション誤差のリスト
戻り値の型: (tuple)
例
>>> train_img_path_list, train_annot_list = ... # Define train data >>> valid_img_path_list, valid_annot_list = ... # Define validation data >>> class_map = ... # Define class map >>> model = VGG19(class_map) # Specify any algorithm provided by ReNomIMG API here >>> model.fit( ... # Feeds image and annotation data ... train_img_path_list, ... train_annot_list, ... valid_img_path_list, ... valid_annot_list, ... epoch=8, ... batch_size=8) >>>
以下の引数はcallback_end_epochに指定された関数に渡されます。
- epoch (int) - 現在のエポック数
- model (Model) - モデルオブジェクト
- avg_train_loss_list (list) - 各エポックの平均学習誤差のリスト
- avg_train_loss_list (list) - 各エポックの平均バリデーション誤差のリスト
-
forward
( x ) ¶ -
順伝播を実行します。この関数は__call__メソッドにより呼ぶことができます。
パラメータ: x ( ndarray , Node ) -- VGG19モデル 戻り値: VGG19の生の出力を返します。 戻り値の型: (Node) 例
>>> import numpy as np >>> x = np.random.rand(1, 3, 224, 224) >>> >>> class_map = ["dog", "cat"] >>> model = VGG19(class_map) >>> >>> y = model.forward(x) # Forward propagation. >>> y = model(x) # Same as above result.
-
loss
( x , y ) ¶ -
VGG19アルゴリズムの誤差関数
パラメータ: - x ( ndarray , Node ) -- モデルの出力
- y ( ndarray , Node ) -- ターゲット配列
戻り値: xとy間の誤差
戻り値の型: (Node)
例
>>> builder = model.build_data() # This will return a builder function. >>> x, y = builder(image_path_list, annotation_list) >>> z = model(x) >>> loss = model.loss(z, y)
-
predict
( img_list , batch_size=1 , return_scores=False ) ¶ -
予測を実行します。引数には画像の配列、画像のパスのリストもしくは画像のパスが可能です。
パラメータ: - img_list ( ndarray , list , string ) -- 画像の配列、画像のパスのリストもしくは画像のパス
- batch_size ( int ) -- 入力画像データの処理に使うバッチサイズ
- return_scores ( bool ) -- 全クラスに対する推論結果のスコア値を返すかどうかのフラグ。デフォルトはFalse。
戻り値: 各画像に対する推論結果を返します。return_scoresフラグがTrueであれば、全クラスに対する推論スコア値も返します。
戻り値の型: (array)
-
preprocess
( x ) ¶ -
与えられた配列に対して、前処理を実行します。
パラメータ: x ( ndarray , Node ) -- 前処理用の画像の配列
-
regularize
( ) ¶ -
誤差関数のL2正則化項
例
>>> x = numpy.random.rand(1, 3, 224, 224) # Input image >>> y = ... # Ground-truth label >>> >>> class_map = ['cat', 'dog'] >>> model = VGG19(class_map) >>> >>> z = model(x) # Forward propagation >>> loss = model.loss(z, y) # Loss calculation >>> reg_loss = loss + model.regularize() # Add weight decay term.
-
class
ResNet101
( class_map=None , imsize=(224 , 224) , plateau=False , load_pretrained_weight=False , train_whole_network=False ) ¶ -
ResNet101モデル
もし引数load_pretrained_weightがTrueなら、事前学習済みの重みがダウンロードされます。事前学習の重みはILSVRC2012を使って学習しています.
パラメータ: - class_map ( list , dict ) -- クラス名の配列
- imsize ( int , tuple ) -- 入力画像サイズ
- plateau ( bool ) -- エラープラトーが発生する場合に学習率を調整するかどうかを指定します。Trueならば、誤差がエラープラトーに入った場合、学習率を自動的に下げます。
- load_pretrained_weight ( bool , str ) -- Trueならば、事前学習済みの重みがカレントディレクトリにダウンロードされます。文字列が与えられた場合は、重みはその名前で保存されます。
- train_whole_network ( bool ) -- モデル全体を学習させる場合はTrue、そうでなければFalse
例
>>> from renom_img.api.classification.resnet import ResNet101 >>> >>> class_map = ["dog", "cat"] >>> model = ResNet101(class_map, imsize=(224,224), plateau=True, load_pretrained_weight=True, train_whole_network=True)
注釈
事前学習のデータセットは1000クラスのため、もし引数num_classが1000でなかった場合は最後のDense層はリセットされます。
参照
Kaiming He, Xiangyu Zhang, Shaoqing Ren, Jian SunDeep Residual Learning for Image Recognition
-
build_data
( ) ¶ -
この関数はResNet101用の入力データと出力データを作成します。
戻り値: 入力データと出力データを作成する関数を返します。 戻り値の型: (function) 例
>>> builder = model.build_data() # This will return function. >>> x, y = builder(image_path_list, annotation_list) >>> z = model(x) >>> loss = model.loss(z, y)
-
fit
( train_img_path_list=None , train_annotation_list=None , valid_img_path_list=None , valid_annotation_list=None , epoch=136 , batch_size=64 , optimizer=None , augmentation=None , callback_end_epoch=None ) ¶ -
この関数は与えられたデータを元に学習を行います。
パラメータ: - train_img_path_list ( list ) -- クラス名の配列
- train_annotation_list ( list ) -- クラス名の配列
- valid_img_path_list ( list ) -- バリデーションの画像のパスのリスト
- valid_annotation_list ( list ) -- バリデーション用のアノテーションのリスト
- epoch ( int ) -- 学習時のエポック数
- batch_size ( int ) -- バッチサイズ
- augmentation ( Augmentation ) -- Augmentationオブジェクト
- callback_end_epoch ( function ) -- 与えらえた関数は各エポックの終了時に呼ばれます。
戻り値: 学習誤差のリストとバリデーション誤差のリスト
戻り値の型: (tuple)
例
>>> train_img_path_list, train_annot_list = ... # Define train data >>> valid_img_path_list, valid_annot_list = ... # Define validation data >>> class_map = ... # Define class map >>> model = ResNet101(class_map) # Specify any algorithm provided by ReNomIMG API here >>> model.fit( ... # Feeds image and annotation data ... train_img_path_list, ... train_annot_list, ... valid_img_path_list, ... valid_annot_list, ... epoch=8, ... batch_size=8) >>>
以下の引数はcallback_end_epochに指定された関数に渡されます。
- epoch (int) - 現在のエポック数
- model (Model) - モデルオブジェクト
- avg_train_loss_list (list) - 各エポックの平均学習誤差のリスト
- avg_train_loss_list (list) - 各エポックの平均バリデーション誤差のリスト
-
forward
( x ) ¶ -
順伝播を実行します。この関数は__call__メソッドにより呼ぶことができます。
パラメータ: x ( ndarray , Node ) -- ResNet101への入力 戻り値: ResNet101の生の出力を返します。 戻り値の型: (Node) 例
>>> import numpy as np >>> x = np.random.rand(1, 3, 224, 224) >>> >>> class_map = ["dog", "cat"] >>> model = ResNet101(class_map) >>> >>> y = model.forward(x) # Forward propagation. >>> y = model(x) # Same as above result.
-
loss
( x , y ) ¶ -
ResNet101アルゴリズムの誤差関数
パラメータ: - x ( ndarray , Node ) -- モデルの出力
- y ( ndarray , Node ) -- ターゲット配列
戻り値: xとy間の誤差
戻り値の型: (Node)
例
>>> builder = model.build_data() # This will return a builder function. >>> x, y = builder(image_path_list, annotation_list) >>> z = model(x) >>> loss = model.loss(z, y)
-
predict
( img_list , batch_size=1 , return_scores=False ) ¶ -
予測を実行します。引数には画像の配列、画像のパスのリストもしくは画像のパスが可能です。
パラメータ: - img_list ( ndarray , list , string ) -- 画像の配列、画像のパスのリストもしくは画像のパス
- batch_size ( int ) -- 入力画像データの処理に使うバッチサイズ
- return_scores ( bool ) -- 全クラスに対する推論結果のスコア値を返すかどうかのフラグ。デフォルトはFalse。
戻り値: 各画像に対する推論結果を返します。return_scoresフラグがTrueであれば、全クラスに対する推論スコア値も返します。
戻り値の型: (array)
-
preprocess
( x ) ¶ -
与えられた配列に対して、前処理を実行します。
パラメータ: x ( ndarray , Node ) -- 前処理用の画像の配列
-
regularize
( ) ¶ -
誤差関数のL2正則化項
例
>>> x = numpy.random.rand(1, 3, 224, 224) # Input image >>> y = ... # Ground-truth label >>> >>> class_map = ['cat', 'dog'] >>> model = ResNet101(class_map) >>> >>> z = model(x) # Forward propagation >>> loss = model.loss(z, y) # Loss calculation >>> reg_loss = loss + model.regularize() # Add weight decay term.
-
class
ResNet152
( class_map=None , imsize=(224 , 224) , plateau=False , load_pretrained_weight=False , train_whole_network=False ) ¶ -
ResNet152モデル
もし引数load_pretrained_weightがTrueなら、事前学習済みの重みがダウンロードされます。事前学習の重みはILSVRC2012を使って学習しています.
パラメータ: - class_map ( list , dict ) -- クラス名の配列
- imsize ( int , tuple ) -- 入力画像サイズ
- plateau ( bool ) -- エラープラトーが発生する場合に学習率を調整するかどうかを指定します。Trueならば、誤差がエラープラトーに入った場合、学習率を自動的に下げます。
- load_pretrained_weight ( bool , str ) -- Trueならば、事前学習済みの重みがカレントディレクトリにダウンロードされます。文字列が与えられた場合は、重みはその名前で保存されます。
- train_whole_network ( bool ) -- モデル全体を学習させる場合はTrue、そうでなければFalse
例
>>> from renom_img.api.classification.resnet import ResNet152 >>> >>> class_map = ["dog", "cat"] >>> model = ResNet152(class_map, imsize=(224,224), plateau=True, load_pretrained_weight=True, train_whole_network=True)
注釈
事前学習のデータセットは1000クラスのため、もし引数num_classが1000でなかった場合は最後のDense層はリセットされます。
参照
Kaiming He, Xiangyu Zhang, Shaoqing Ren, Jian SunDeep Residual Learning for Image Recognition
-
build_data
( ) ¶ -
この関数はResNet152用の入力データとターゲットデータを作成する関数を返します。
戻り値: 入力データと出力データを作成する関数を返します。 戻り値の型: (function) 例
>>> builder = model.build_data() # This will return function. >>> x, y = builder(image_path_list, annotation_list) >>> z = model(x) >>> loss = model.loss(z, y)
-
fit
( train_img_path_list=None , train_annotation_list=None , valid_img_path_list=None , valid_annotation_list=None , epoch=136 , batch_size=64 , optimizer=None , augmentation=None , callback_end_epoch=None ) ¶ -
この関数は与えられたデータを元に学習を行います。
パラメータ: - train_img_path_list ( list ) -- クラス名の配列
- train_annotation_list ( list ) -- クラス名の配列
- valid_img_path_list ( list ) -- バリデーションの画像のパスのリスト
- valid_annotation_list ( list ) -- バリデーション用のアノテーションのリスト
- epoch ( int ) -- 学習時のエポック数
- batch_size ( int ) -- バッチサイズ
- augmentation ( Augmentation ) -- Augmentationオブジェクト
- callback_end_epoch ( function ) -- 与えらえた関数は各エポックの終了時に呼ばれます。
戻り値: 学習誤差のリストとバリデーション誤差のリスト
戻り値の型: (tuple)
例
>>> train_img_path_list, train_annot_list = ... # Define train data >>> valid_img_path_list, valid_annot_list = ... # Define validation data >>> class_map = ... # Define class map >>> model = ResNet152(class_map) # Specify any algorithm provided by ReNomIMG API here >>> model.fit( ... # Feeds image and annotation data ... train_img_path_list, ... train_annot_list, ... valid_img_path_list, ... valid_annot_list, ... epoch=8, ... batch_size=8) >>>
以下の引数はcallback_end_epochに指定された関数に渡されます。
- epoch (int) - 現在のエポック数
- model (Model) - モデルオブジェクト
- avg_train_loss_list (list) - 各エポックの平均学習誤差のリスト
- avg_train_loss_list (list) - 各エポックの平均バリデーション誤差のリスト
-
forward
( x ) ¶ -
順伝播を実行します。この関数は__call__メソッドにより呼ぶことができます。
パラメータ: x ( ndarray , Node ) -- ResNet152モデル 戻り値: ResNet152の生の出力を返します。 戻り値の型: (Node) 例
>>> import numpy as np >>> x = np.random.rand(1, 3, 224, 224) >>> >>> class_map = ["dog", "cat"] >>> model = ResNet152(class_map) >>> >>> y = model.forward(x) # Forward propagation. >>> y = model(x) # Same as above result.
-
loss
( x , y ) ¶ -
ResNet152アルゴリズムの誤差関数
パラメータ: - x ( ndarray , Node ) -- モデルの出力
- y ( ndarray , Node ) -- ターゲット配列
戻り値: xとy間の誤差
戻り値の型: (Node)
例
>>> builder = model.build_data() # This will return a builder function. >>> x, y = builder(image_path_list, annotation_list) >>> z = model(x) >>> loss = model.loss(z, y)
-
predict
( img_list , batch_size=1 , return_scores=False ) ¶ -
予測を実行します。引数には画像の配列、画像のパスのリストもしくは画像のパスが可能です。
パラメータ: - img_list ( ndarray , list , string ) -- 画像の配列、画像のパスのリストもしくは画像のパス
- batch_size ( int ) -- 入力画像データの処理に使うバッチサイズ
- return_scores ( bool ) -- 全クラスに対する推論結果のスコア値を返すかどうかのフラグ。デフォルトはFalse。
戻り値: 各画像に対する推論結果を返します。return_scoresフラグがTrueであれば、全クラスに対する推論スコア値も返します。
戻り値の型: (array)
-
preprocess
( x ) ¶ -
与えられた配列に対して、前処理を実行します。
パラメータ: x ( ndarray , Node ) -- 前処理用の画像の配列
-
regularize
( ) ¶ -
誤差関数のL2正則化項
例
>>> x = numpy.random.rand(1, 3, 224, 224) # Input image >>> y = ... # Ground-truth label >>> >>> class_map = ['cat', 'dog'] >>> model = ResNet152(class_map) >>> >>> z = model(x) # Forward propagation >>> loss = model.loss(z, y) # Loss calculation >>> reg_loss = loss + model.regularize() # Add weight decay term.
-
class
ResNet18
( class_map=None , imsize=(224 , 224) , plateau=False , load_pretrained_weight=False , train_whole_network=False ) ¶ -
ResNet18モデル
もし引数load_pretrained_weightがTrueなら、事前学習済みの重みがダウンロードされます。事前学習の重みはILSVRC2012を使って学習しています.
パラメータ: - class_map ( list , dict ) -- クラス名の配列
- imsize ( int , tuple ) -- 入力画像サイズ
- plateau ( bool ) -- エラープラトーが発生する場合に学習率を調整するかどうかを指定します。Trueならば、誤差がエラープラトーに入った場合、学習率を自動的に下げます。
- load_pretrained_weight ( bool , str ) -- Trueならば、事前学習済みの重みがカレントディレクトリにダウンロードされます。文字列が与えられた場合は、重みはその名前で保存されます。
- train_whole_network ( bool ) -- モデル全体を学習させる場合はTrue、そうでなければFalse
例
>>> from renom_img.api.classification.resnet import ResNet18 >>> >>> class_map = ["dog", "cat"] >>> model = ResNet18(class_map, imsize=(224,224), plateau=True, load_pretrained_weight=True, train_whole_network=True)
注釈
事前学習のデータセットは1000クラスのため、もし引数num_classが1000でなかった場合は最後のDense層はリセットされます。
参照
Kaiming He, Xiangyu Zhang, Shaoqing Ren, Jian SunDeep Residual Learning for Image Recognition
-
build_data
( ) ¶ -
この関数はResNet18用の入力データとターゲットデータを作成する関数を返します。
戻り値: 入力データと出力データを作成する関数を返します。 戻り値の型: (function) 例
>>> builder = model.build_data() # This will return function. >>> x, y = builder(image_path_list, annotation_list) >>> z = model(x) >>> loss = model.loss(z, y)
-
fit
( train_img_path_list=None , train_annotation_list=None , valid_img_path_list=None , valid_annotation_list=None , epoch=136 , batch_size=64 , optimizer=None , augmentation=None , callback_end_epoch=None ) ¶ -
この関数は与えられたデータを元に学習を行います。
パラメータ: - train_img_path_list ( list ) -- クラス名の配列
- train_annotation_list ( list ) -- クラス名の配列
- valid_img_path_list ( list ) -- バリデーションの画像のパスのリスト
- valid_annotation_list ( list ) -- バリデーション用のアノテーションのリスト
- epoch ( int ) -- 学習時のエポック数
- batch_size ( int ) -- バッチサイズ
- augmentation ( Augmentation ) -- Augmentationオブジェクト
- callback_end_epoch ( function ) -- 与えらえた関数は各エポックの終了時に呼ばれます。
戻り値: 学習誤差のリストとバリデーション誤差のリスト
戻り値の型: (tuple)
例
>>> train_img_path_list, train_annot_list = ... # Define train data >>> valid_img_path_list, valid_annot_list = ... # Define validation data >>> class_map = ... # Define class map >>> model = ResNet18(class_map) # Specify any algorithm provided by ReNomIMG API here >>> model.fit( ... # Feeds image and annotation data ... train_img_path_list, ... train_annot_list, ... valid_img_path_list, ... valid_annot_list, ... epoch=8, ... batch_size=8) >>>
以下の引数はcallback_end_epochに指定された関数に渡されます。
- epoch (int) - 現在のエポック数
- model (Model) - モデルオブジェクト
- avg_train_loss_list (list) - 各エポックの平均学習誤差のリスト
- avg_train_loss_list (list) - 各エポックの平均バリデーション誤差のリスト
-
forward
( x ) ¶ -
順伝播を実行します。この関数は__call__メソッドにより呼ぶことができます。
パラメータ: x ( ndarray , Node ) -- ResNet18への入力 戻り値: ResNet18の生の出力を返します。 戻り値の型: (Node) 例
>>> import numpy as np >>> x = np.random.rand(1, 3, 224, 224) >>> >>> class_map = ["dog", "cat"] >>> model = ResNet18(class_map) >>> >>> y = model.forward(x) # Forward propagation. >>> y = model(x) # Same as above result.
-
loss
( x , y ) ¶ -
ResNet18アルゴリズムの誤差関数
パラメータ: - x ( ndarray , Node ) -- モデルの出力
- y ( ndarray , Node ) -- ターゲット配列
戻り値: xとy間の誤差
戻り値の型: (Node)
例
>>> builder = model.build_data() # This will return a builder function. >>> x, y = builder(image_path_list, annotation_list) >>> z = model(x) >>> loss = model.loss(z, y)
-
predict
( img_list , batch_size=1 , return_scores=False ) ¶ -
予測を実行します。引数には画像の配列、画像のパスのリストもしくは画像のパスが可能です。
パラメータ: - img_list ( ndarray , list , string ) -- 画像の配列、画像のパスのリストもしくは画像のパス
- batch_size ( int ) -- 入力画像データの処理に使うバッチサイズ
- return_scores ( bool ) -- 全クラスに対する推論結果のスコア値を返すかどうかのフラグ。デフォルトはFalse。
戻り値: 各画像に対する推論結果を返します。return_scoresフラグがTrueであれば、全クラスに対する推論スコア値も返します。
戻り値の型: (array)
-
preprocess
( x ) ¶ -
与えられた配列に対して、前処理を実行します。
パラメータ: x ( ndarray , Node ) -- 前処理用の画像の配列
-
regularize
( ) ¶ -
誤差関数のL2正則化項
例
>>> x = numpy.random.rand(1, 3, 224, 224) # Input image >>> y = ... # Ground-truth label >>> >>> class_map = ['cat', 'dog'] >>> model = ResNet18(class_map) >>> >>> z = model(x) # Forward propagation >>> loss = model.loss(z, y) # Loss calculation >>> reg_loss = loss + model.regularize() # Add weight decay term.
-
class
ResNet34
( class_map=None , imsize=(224 , 224) , plateau=False , load_pretrained_weight=False , train_whole_network=False ) ¶ -
ResNet34モデル
もし引数load_pretrained_weightがTrueなら、事前学習済みの重みがダウンロードされます。事前学習の重みはILSVRC2012を使って学習しています.
パラメータ: - class_map ( list , dict ) -- クラス名の配列
- imsize ( int , tuple ) -- 入力画像サイズ
- plateau ( bool ) -- エラープラトーが発生する場合に学習率を調整するかどうかを指定します。Trueならば、誤差がエラープラトーに入った場合、学習率を自動的に下げます。
- load_pretrained_weight ( bool , str ) -- Trueならば、事前学習済みの重みがカレントディレクトリにダウンロードされます。文字列が与えられた場合は、重みはその名前で保存されます。
- train_whole_network ( bool ) -- モデル全体を学習させる場合はTrue、そうでなければFalse
例
>>> from renom_img.api.classification.resnet import ResNet34 >>> >>> class_map = ["dog", "cat"] >>> model = ResNet34(class_map, imsize=(224,224), plateau=True, load_pretrained_weight=True, train_whole_network=True)
注釈
事前学習のデータセットは1000クラスのため、もし引数num_classが1000でなかった場合は最後のDense層はリセットされます。
参照
Kaiming He, Xiangyu Zhang, Shaoqing Ren, Jian SunDeep Residual Learning for Image Recognition
-
build_data
( ) ¶ -
この関数はResNet34用の入力データとターゲットデータを作成する関数を返します。
戻り値: 入力データと出力データを作成する関数を返します。 戻り値の型: (function) 例
>>> builder = model.build_data() # This will return function. >>> x, y = builder(image_path_list, annotation_list) >>> z = model(x) >>> loss = model.loss(z, y)
-
fit
( train_img_path_list=None , train_annotation_list=None , valid_img_path_list=None , valid_annotation_list=None , epoch=136 , batch_size=64 , optimizer=None , augmentation=None , callback_end_epoch=None ) ¶ -
この関数は与えられたデータを元に学習を行います。
パラメータ: - train_img_path_list ( list ) -- クラス名の配列
- train_annotation_list ( list ) -- クラス名の配列
- valid_img_path_list ( list ) -- バリデーションの画像のパスのリスト
- valid_annotation_list ( list ) -- バリデーション用のアノテーションのリスト
- epoch ( int ) -- 学習時のエポック数
- batch_size ( int ) -- バッチサイズ
- augmentation ( Augmentation ) -- Augmentationオブジェクト
- callback_end_epoch ( function ) -- 与えらえた関数は各エポックの終了時に呼ばれます。
戻り値: 学習誤差のリストとバリデーション誤差のリスト
戻り値の型: (tuple)
例
>>> train_img_path_list, train_annot_list = ... # Define train data >>> valid_img_path_list, valid_annot_list = ... # Define validation data >>> class_map = ... # Define class map >>> model = ResNet34(class_map) # Specify any algorithm provided by ReNomIMG API here >>> model.fit( ... # Feeds image and annotation data ... train_img_path_list, ... train_annot_list, ... valid_img_path_list, ... valid_annot_list, ... epoch=8, ... batch_size=8) >>>
以下の引数はcallback_end_epochに指定された関数に渡されます。
- epoch (int) - 現在のエポック数
- model (Model) - モデルオブジェクト
- avg_train_loss_list (list) - 各エポックの平均学習誤差のリスト
- avg_train_loss_list (list) - 各エポックの平均バリデーション誤差のリスト
-
forward
( x ) ¶ -
順伝播を実行します。この関数は__call__メソッドにより呼ぶことができます。
パラメータ: x ( ndarray , Node ) -- ResNet34への入力 戻り値: ResNet34の生の出力を返します。 戻り値の型: (Node) 例
>>> import numpy as np >>> x = np.random.rand(1, 3, 224, 224) >>> >>> class_map = ["dog", "cat"] >>> model = ResNet34(class_map) >>> >>> y = model.forward(x) # Forward propagation. >>> y = model(x) # Same as above result.
-
loss
( x , y ) ¶ -
ResNet34アルゴリズムの誤差関数
パラメータ: - x ( ndarray , Node ) -- モデルの出力
- y ( ndarray , Node ) -- ターゲット配列
戻り値: xとy間の誤差
戻り値の型: (Node)
例
>>> builder = model.build_data() # This will return a builder function. >>> x, y = builder(image_path_list, annotation_list) >>> z = model(x) >>> loss = model.loss(z, y)
-
predict
( img_list , batch_size=1 , return_scores=False ) ¶ -
予測を実行します。引数には画像の配列、画像のパスのリストもしくは画像のパスが可能です。
パラメータ: - img_list ( ndarray , list , string ) -- 画像の配列、画像のパスのリストもしくは画像のパス
- batch_size ( int ) -- 入力画像データの処理に使うバッチサイズ
- return_scores ( bool ) -- 全クラスに対する推論結果のスコア値を返すかどうかのフラグ。デフォルトはFalse。
戻り値: 各画像に対する推論結果を返します。return_scoresフラグがTrueであれば、全クラスに対する推論スコア値も返します。
戻り値の型: (array)
-
preprocess
( x ) ¶ -
与えられた配列に対して、前処理を実行します。
パラメータ: x ( ndarray , Node ) -- 前処理用の画像の配列
-
regularize
( ) ¶ -
誤差関数のL2正則化項
例
>>> x = numpy.random.rand(1, 3, 224, 224) # Input image >>> y = ... # Ground-truth label >>> >>> class_map = ['cat', 'dog'] >>> model = ResNet34(class_map) >>> >>> z = model(x) # Forward propagation >>> loss = model.loss(z, y) # Loss calculation >>> reg_loss = loss + model.regularize() # Add weight decay term.
-
class
ResNet50
( class_map=None , imsize=(224 , 224) , plateau=False , load_pretrained_weight=False , train_whole_network=False ) ¶ -
ResNet50モデル
もし引数load_pretrained_weightがTrueなら、事前学習済みの重みがダウンロードされます。事前学習の重みはILSVRC2012を使って学習しています.
パラメータ: - class_map ( list , dict ) -- クラス名の配列
- imsize ( int , tuple ) -- 入力画像サイズ
- plateau ( bool ) -- エラープラトーが発生する場合に学習率を調整するかどうかを指定します。Trueならば、誤差がエラープラトーに入った場合、学習率を自動的に下げます。
- load_pretrained_weight ( bool , str ) -- Trueならば、事前学習済みの重みがカレントディレクトリにダウンロードされます。文字列が与えられた場合は、重みはその名前で保存されます。
- train_whole_network ( bool ) -- モデル全体を学習させる場合はTrue、そうでなければFalse
例
>>> from renom_img.api.classification.resnet import ResNet50 >>> >>> class_map = ["dog", "cat"] >>> model = ResNet50(class_map, imsize=(224,224), plateau=True, load_pretrained_weight=True, train_whole_network=True)
注釈
事前学習のデータセットは1000クラスのため、もし引数num_classが1000でなかった場合は最後のDense層はリセットされます。
参照
Kaiming He, Xiangyu Zhang, Shaoqing Ren, Jian SunDeep Residual Learning for Image Recognition
-
build_data
( ) ¶ -
この関数はResNet50用の入力データとターゲットデータを作成する関数を返します。
戻り値: 入力データと出力データを作成する関数を返します。 戻り値の型: (function) 例
>>> builder = model.build_data() # This will return function. >>> x, y = builder(image_path_list, annotation_list) >>> z = model(x) >>> loss = model.loss(z, y)
-
fit
( train_img_path_list=None , train_annotation_list=None , valid_img_path_list=None , valid_annotation_list=None , epoch=136 , batch_size=64 , optimizer=None , augmentation=None , callback_end_epoch=None ) ¶ -
この関数は与えられたデータを元に学習を行います。
パラメータ: - train_img_path_list ( list ) -- クラス名の配列
- train_annotation_list ( list ) -- クラス名の配列
- valid_img_path_list ( list ) -- バリデーションの画像のパスのリスト
- valid_annotation_list ( list ) -- バリデーション用のアノテーションのリスト
- epoch ( int ) -- 学習時のエポック数
- batch_size ( int ) -- バッチサイズ
- augmentation ( Augmentation ) -- Augmentationオブジェクト
- callback_end_epoch ( function ) -- 与えらえた関数は各エポックの終了時に呼ばれます。
戻り値: 学習誤差のリストとバリデーション誤差のリスト
戻り値の型: (tuple)
例
>>> train_img_path_list, train_annot_list = ... # Define train data >>> valid_img_path_list, valid_annot_list = ... # Define validation data >>> class_map = ... # Define class map >>> model = ResNet50(class_map) # Specify any algorithm provided by ReNomIMG API here >>> model.fit( ... # Feeds image and annotation data ... train_img_path_list, ... train_annot_list, ... valid_img_path_list, ... valid_annot_list, ... epoch=8, ... batch_size=8) >>>
以下の引数はcallback_end_epochに指定された関数に渡されます。
- epoch (int) - 現在のエポック数
- model (Model) - モデルオブジェクト
- avg_train_loss_list (list) - 各エポックの平均学習誤差のリスト
- avg_train_loss_list (list) - 各エポックの平均バリデーション誤差のリスト
-
forward
( x ) ¶ -
順伝播を実行します。この関数は__call__メソッドにより呼ぶことができます。
パラメータ: x ( ndarray , Node ) -- ResNet50への入力 戻り値: ResNet50の生の出力を返します。 戻り値の型: (Node) 例
>>> import numpy as np >>> x = np.random.rand(1, 3, 224, 224) >>> >>> class_map = ["dog", "cat"] >>> model = ResNet50(class_map) >>> >>> y = model.forward(x) # Forward propagation. >>> y = model(x) # Same as above result.
-
loss
( x , y ) ¶ -
ResNet50アルゴリズムの誤差関数
パラメータ: - x ( ndarray , Node ) -- モデルの出力
- y ( ndarray , Node ) -- ターゲット配列
戻り値: xとy間の誤差
戻り値の型: (Node)
例
>>> builder = model.build_data() # This will return a builder function. >>> x, y = builder(image_path_list, annotation_list) >>> z = model(x) >>> loss = model.loss(z, y)
-
predict
( img_list , batch_size=1 , return_scores=False ) ¶ -
予測を実行します。引数には画像の配列、画像のパスのリストもしくは画像のパスが可能です。
パラメータ: - img_list ( ndarray , list , string ) -- 画像の配列、画像のパスのリストもしくは画像のパス
- batch_size ( int ) -- 入力画像データの処理に使うバッチサイズ
- return_scores ( bool ) -- 全クラスに対する推論結果のスコア値を返すかどうかのフラグ。デフォルトはFalse。
戻り値: 各画像に対する推論結果を返します。return_scoresフラグがTrueであれば、全クラスに対する推論スコア値も返します。
戻り値の型: (array)
-
preprocess
( x ) ¶ -
与えられた配列に対して、前処理を実行します。
パラメータ: x ( ndarray , Node ) -- 前処理用の画像の配列
-
regularize
( ) ¶ -
誤差関数のL2正則化項
例
>>> x = numpy.random.rand(1, 3, 224, 224) # Input image >>> y = ... # Ground-truth label >>> >>> class_map = ['cat', 'dog'] >>> model = ResNet50(class_map) >>> >>> z = model(x) # Forward propagation >>> loss = model.loss(z, y) # Loss calculation >>> reg_loss = loss + model.regularize() # Add weight decay term.
-
class
ResNeXt101
( class_map=None , imsize=(224 , 224) , cardinality=32 , plateau=False , load_pretrained_weight=False , train_whole_network=False ) ¶ -
ResNeXt101モデル
もし引数load_pretrained_weightがTrueなら、事前学習済みの重みがダウンロードされます。事前学習の重みはILSVRC2012を使って学習しています.
パラメータ: - class_map ( list , dict ) -- クラス名の配列
- imsize ( int , tuple ) -- 入力画像サイズ
- cardinality ( int ) -- グループ畳み込み層のグループ数
- plateau ( bool ) -- エラープラトーが発生する場合に学習率を調整するかどうかを指定します。Trueならば、誤差がエラープラトーに入った場合、学習率を自動的に下げます。
- load_pretrained_weight ( bool , str ) -- Trueならば、事前学習済みの重みがカレントディレクトリにダウンロードされます。文字列が与えられた場合は、重みはその名前で保存されます。
- train_whole_network ( bool ) -- モデル全体を学習させる場合はTrue、そうでなければFalse
例
>>> from renom_img.api.classification.resnext import ResNeXt101 >>> >>> class_map = ["dog", "cat"] >>> model = ResNeXt101(class_map, imsize=(224,224), plateau=True, load_pretrained_weight=True, train_whole_network=True)
注釈
事前学習のデータセットは1000クラスのため、もし引数num_classが1000でなかった場合は最後のDense層はリセットされます。
参照
Saining Xie, Ross Girshick, Piotr Dollar, Zhuowen Tu, Kaiming HeAggregated Residual Transformations for Deep Neural Networks
-
build_data
( ) ¶ -
この関数はResNeXt101用の入力データと出力データを作成します。
戻り値: 入力データと出力データを作成する関数を返します。 戻り値の型: (function) 例
>>> builder = model.build_data() # This will return function. >>> x, y = builder(image_path_list, annotation_list) >>> z = model(x) >>> loss = model.loss(z, y)
-
fit
( train_img_path_list=None , train_annotation_list=None , valid_img_path_list=None , valid_annotation_list=None , epoch=136 , batch_size=64 , optimizer=None , augmentation=None , callback_end_epoch=None ) ¶ -
この関数は与えられたデータを元に学習を行います。
パラメータ: - train_img_path_list ( list ) -- クラス名の配列
- train_annotation_list ( list ) -- クラス名の配列
- valid_img_path_list ( list ) -- バリデーションの画像のパスのリスト
- valid_annotation_list ( list ) -- バリデーション用のアノテーションのリスト
- epoch ( int ) -- 学習時のエポック数
- batch_size ( int ) -- バッチサイズ
- augmentation ( Augmentation ) -- Augmentationオブジェクト
- callback_end_epoch ( function ) -- 与えらえた関数は各エポックの終了時に呼ばれます。
戻り値: 学習誤差のリストとバリデーション誤差のリスト
戻り値の型: (tuple)
例
>>> train_img_path_list, train_annot_list = ... # Define train data >>> valid_img_path_list, valid_annot_list = ... # Define validation data >>> class_map = ... # Define class map >>> model = ResNeXt101(class_map) # Specify any algorithm provided by ReNomIMG API here >>> model.fit( ... # Feeds image and annotation data ... train_img_path_list, ... train_annot_list, ... valid_img_path_list, ... valid_annot_list, ... epoch=8, ... batch_size=8) >>>
以下の引数はcallback_end_epochに指定された関数に渡されます。
- epoch (int) - 現在のエポック数
- model (Model) - モデルオブジェクト
- avg_train_loss_list (list) - 各エポックの平均学習誤差のリスト
- avg_train_loss_list (list) - 各エポックの平均バリデーション誤差のリスト
-
forward
( x ) ¶ -
順伝播を実行します。この関数は__call__メソッドにより呼ぶことができます。
パラメータ: x ( ndarray , Node ) -- ResNeXt101への入力 戻り値: ResNeXt101の生の出力を返します。 戻り値の型: (Node) 例
>>> import numpy as np >>> x = np.random.rand(1, 3, 224, 224) >>> >>> class_map = ["dog", "cat"] >>> model = ResNeXt101(class_map) >>> >>> y = model.forward(x) # Forward propagation. >>> y = model(x) # Same as above result.
-
loss
( x , y ) ¶ -
ResNeXt101アルゴリズムの誤差関数
パラメータ: - x ( ndarray , Node ) -- モデルの出力
- y ( ndarray , Node ) -- ターゲット配列
戻り値: xとy間の誤差
戻り値の型: (Node)
例
>>> builder = model.build_data() # This will return a builder function. >>> x, y = builder(image_path_list, annotation_list) >>> z = model(x) >>> loss = model.loss(z, y)
-
predict
( img_list , batch_size=1 , return_scores=False ) ¶ -
予測を実行します。引数には画像の配列、画像のパスのリストもしくは画像のパスが可能です。
パラメータ: - img_list ( ndarray , list , string ) -- 画像の配列、画像のパスのリストもしくは画像のパス
- batch_size ( int ) -- 入力画像データの処理に使うバッチサイズ
- return_scores ( bool ) -- 全クラスに対する推論結果のスコア値を返すかどうかのフラグ。デフォルトはFalse。
戻り値: 各画像に対する推論結果を返します。return_scoresフラグがTrueであれば、全クラスに対する推論スコア値も返します。
戻り値の型: (array)
-
preprocess
( x ) ¶ -
与えられた配列に対して、前処理を実行します。
パラメータ: x ( ndarray , Node ) -- 前処理用の画像の配列
-
regularize
( ) ¶ -
誤差関数のL2正則化項
例
>>> x = numpy.random.rand(1, 3, 224, 224) # Input image >>> y = ... # Ground-truth label >>> >>> class_map = ['cat', 'dog'] >>> model = ResNeXt101(class_map) >>> >>> z = model(x) # Forward propagation >>> loss = model.loss(z, y) # Loss calculation >>> reg_loss = loss + model.regularize() # Add weight decay term.
-
class
ResNeXt50
( class_map=None , imsize=(224 , 224) , cardinality=32 , plateau=False , load_pretrained_weight=False , train_whole_network=False ) ¶ -
ResNeXt50モデル
もし引数load_pretrained_weightがTrueなら、事前学習済みの重みがダウンロードされます。事前学習の重みはILSVRC2012を使って学習しています.
パラメータ: - class_map ( list , dict ) -- クラス名の配列
- imsize ( int , tuple ) -- 入力画像サイズ
- cardinality ( int ) -- グループ畳み込み層のグループ数
- plateau ( bool ) -- エラープラトーが発生する場合に学習率を調整するかどうかを指定します。Trueならば、誤差がエラープラトーに入った場合、学習率を自動的に下げます。
- load_pretrained_weight ( bool , str ) -- Trueならば、事前学習済みの重みがカレントディレクトリにダウンロードされます。文字列が与えられた場合は、重みはその名前で保存されます。
- train_whole_network ( bool ) -- モデル全体を学習させる場合はTrue、そうでなければFalse
例
>>> from renom_img.api.classification.resnext import ResNeXt50 >>> >>> class_map = ["dog", "cat"] >>> model = ResNeXt50(class_map, imsize=(224,224), plateau=True, load_pretrained_weight=True, train_whole_network=True)
注釈
事前学習のデータセットは1000クラスのため、もし引数num_classが1000でなかった場合は最後のDense層はリセットされます。
参照
Saining Xie, Ross Girshick, Piotr Dollar, Zhuowen Tu, Kaiming HeAggregated Residual Transformations for Deep Neural Networks
-
build_data
( ) ¶ -
この関数はResNeXt50用の入力データとターゲットデータを作成する関数を返します。
戻り値: 入力データと出力データを作成する関数を返します。 戻り値の型: (function) 例
>>> builder = model.build_data() # This will return function. >>> x, y = builder(image_path_list, annotation_list) >>> z = model(x) >>> loss = model.loss(z, y)
-
fit
( train_img_path_list=None , train_annotation_list=None , valid_img_path_list=None , valid_annotation_list=None , epoch=136 , batch_size=64 , optimizer=None , augmentation=None , callback_end_epoch=None ) ¶ -
この関数は与えられたデータを元に学習を行います。
パラメータ: - train_img_path_list ( list ) -- クラス名の配列
- train_annotation_list ( list ) -- クラス名の配列
- valid_img_path_list ( list ) -- バリデーションの画像のパスのリスト
- valid_annotation_list ( list ) -- バリデーション用のアノテーションのリスト
- epoch ( int ) -- 学習時のエポック数
- batch_size ( int ) -- バッチサイズ
- augmentation ( Augmentation ) -- Augmentationオブジェクト
- callback_end_epoch ( function ) -- 与えらえた関数は各エポックの終了時に呼ばれます。
戻り値: 学習誤差のリストとバリデーション誤差のリスト
戻り値の型: (tuple)
例
>>> train_img_path_list, train_annot_list = ... # Define train data >>> valid_img_path_list, valid_annot_list = ... # Define validation data >>> class_map = ... # Define class map >>> model = ResNeXt50(class_map) # Specify any algorithm provided by ReNomIMG API here >>> model.fit( ... # Feeds image and annotation data ... train_img_path_list, ... train_annot_list, ... valid_img_path_list, ... valid_annot_list, ... epoch=8, ... batch_size=8) >>>
以下の引数はcallback_end_epochに指定された関数に渡されます。
- epoch (int) - 現在のエポック数
- model (Model) - モデルオブジェクト
- avg_train_loss_list (list) - 各エポックの平均学習誤差のリスト
- avg_train_loss_list (list) - 各エポックの平均バリデーション誤差のリスト
-
forward
( x ) ¶ -
順伝播を実行します。この関数は__call__メソッドにより呼ぶことができます。
パラメータ: x ( ndarray , Node ) -- ResNeXt50への入力 戻り値: ResNeXt50の生の出力を返します。 戻り値の型: (Node) 例
>>> import numpy as np >>> x = np.random.rand(1, 3, 224, 224) >>> >>> class_map = ["dog", "cat"] >>> model = ResNeXt50(class_map) >>> >>> y = model.forward(x) # Forward propagation. >>> y = model(x) # Same as above result.
-
loss
( x , y ) ¶ -
ResNeXt50アルゴリズムの誤差関数
パラメータ: - x ( ndarray , Node ) -- モデルの出力
- y ( ndarray , Node ) -- ターゲット配列
戻り値: xとy間の誤差
戻り値の型: (Node)
例
>>> builder = model.build_data() # This will return a builder function. >>> x, y = builder(image_path_list, annotation_list) >>> z = model(x) >>> loss = model.loss(z, y)
-
predict
( img_list , batch_size=1 , return_scores=False ) ¶ -
予測を実行します。引数には画像の配列、画像のパスのリストもしくは画像のパスが可能です。
パラメータ: - img_list ( ndarray , list , string ) -- 画像の配列、画像のパスのリストもしくは画像のパス
- batch_size ( int ) -- 入力画像データの処理に使うバッチサイズ
- return_scores ( bool ) -- 全クラスに対する推論結果のスコア値を返すかどうかのフラグ。デフォルトはFalse。
戻り値: 各画像に対する推論結果を返します。return_scoresフラグがTrueであれば、全クラスに対する推論スコア値も返します。
戻り値の型: (array)
-
preprocess
( x ) ¶ -
与えられた配列に対して、前処理を実行します。
パラメータ: x ( ndarray , Node ) -- 前処理用の画像の配列
-
regularize
( ) ¶ -
誤差関数のL2正則化項
例
>>> x = numpy.random.rand(1, 3, 224, 224) # Input image >>> y = ... # Ground-truth label >>> >>> class_map = ['cat', 'dog'] >>> model = ResNeXt50(class_map) >>> >>> z = model(x) # Forward propagation >>> loss = model.loss(z, y) # Loss calculation >>> reg_loss = loss + model.regularize() # Add weight decay term.
-
class
DenseNet121
( class_map=None , imsize=(224 , 224) , load_pretrained_weight=False , train_whole_network=False ) ¶ -
DenseNet121モデル
もし引数load_pretrained_weightがTrueなら、事前学習済みの重みがダウンロードされます。事前学習の重みはILSVRC2012を使って学習しています.
パラメータ: - class_map -- クラス名の配列
- growth_rate ( int ) -- Growth rate of the number of filters.
- imsize ( int or tuple ) -- 入力画像サイズ
- train_whole_network ( bool ) -- True if the overal model is trained.
注釈
事前学習のデータセットは1000クラスのため、もし引数num_classが1000でなかった場合は最後のDense層はリセットされます。
参照
Gao Huang, Zhuang Liu, Laurens van der Maaten, Kilian Q. Weinberger Densely Connected Convolutional Network https://arxiv.org/pdf/1608.06993.pdf
-
build_data
( ) ¶ -
この関数はDenseNet121用の入力データとターゲットデータを作成する関数を返します。
戻り値: 入力データと出力データを作成する関数を返します。 戻り値の型: (function) 例
>>> builder = model.build_data() # This will return function. >>> x, y = builder(image_path_list, annotation_list) >>> z = model(x) >>> loss = model.loss(z, y)
-
fit
( train_img_path_list=None , train_annotation_list=None , valid_img_path_list=None , valid_annotation_list=None , epoch=136 , batch_size=64 , optimizer=None , augmentation=None , callback_end_epoch=None ) ¶ -
この関数は与えられたデータを元に学習を行います。
パラメータ: - train_img_path_list ( list ) -- クラス名の配列
- train_annotation_list ( list ) -- クラス名の配列
- valid_img_path_list ( list ) -- バリデーションの画像のパスのリスト
- valid_annotation_list ( list ) -- バリデーション用のアノテーションのリスト
- epoch ( int ) -- 学習時のエポック数
- batch_size ( int ) -- バッチサイズ
- augmentation ( Augmentation ) -- Augmentationオブジェクト
- callback_end_epoch ( function ) -- 与えらえた関数は各エポックの終了時に呼ばれます。
戻り値: 学習誤差のリストとバリデーション誤差のリスト
戻り値の型: (tuple)
例
>>> train_img_path_list, train_annot_list = ... # Define train data >>> valid_img_path_list, valid_annot_list = ... # Define validation data >>> class_map = ... # Define class map >>> model = DenseNet121(class_map) # Specify any algorithm provided by ReNomIMG API here >>> model.fit( ... # Feeds image and annotation data ... train_img_path_list, ... train_annot_list, ... valid_img_path_list, ... valid_annot_list, ... epoch=8, ... batch_size=8) >>>
以下の引数はcallback_end_epochに指定された関数に渡されます。
- epoch (int) - 現在のエポック数
- model (Model) - モデルオブジェクト
- avg_train_loss_list (list) - 各エポックの平均学習誤差のリスト
- avg_train_loss_list (list) - 各エポックの平均バリデーション誤差のリスト
-
forward
( x ) ¶ -
順伝播を実行します。この関数は__call__メソッドにより呼ぶことができます。
パラメータ: x ( ndarray , Node ) -- DenseNet121への入力 戻り値: DenseNet121の生の出力を返します。 戻り値の型: (Node) 例
>>> import numpy as np >>> x = np.random.rand(1, 3, 224, 224) >>> >>> class_map = ["dog", "cat"] >>> model = DenseNet121(class_map) >>> >>> y = model.forward(x) # Forward propagation. >>> y = model(x) # Same as above result.
-
loss
( x , y ) ¶ -
DenseNet121アルゴリズムの誤差関数
パラメータ: - x ( ndarray , Node ) -- モデルの出力
- y ( ndarray , Node ) -- ターゲット配列
戻り値: xとy間の誤差
戻り値の型: (Node)
例
>>> builder = model.build_data() # This will return a builder function. >>> x, y = builder(image_path_list, annotation_list) >>> z = model(x) >>> loss = model.loss(z, y)
-
predict
( img_list , batch_size=1 , return_scores=False ) ¶ -
予測を実行します。引数には画像の配列、画像のパスのリストもしくは画像のパスが可能です。
パラメータ: - img_list ( ndarray , list , string ) -- 画像の配列、画像のパスのリストもしくは画像のパス
- batch_size ( int ) -- 入力画像データの処理に使うバッチサイズ
- return_scores ( bool ) -- 全クラスに対する推論結果のスコア値を返すかどうかのフラグ。デフォルトはFalse。
戻り値: 各画像に対する推論結果を返します。return_scoresフラグがTrueであれば、全クラスに対する推論スコア値も返します。
戻り値の型: (array)
-
preprocess
( x ) ¶ -
与えられた配列に対して、前処理を実行します。
パラメータ: x ( ndarray , Node ) -- 前処理用の画像の配列
-
regularize
( ) ¶ -
誤差関数のL2正則化項
例
>>> x = numpy.random.rand(1, 3, 224, 224) # Input image >>> y = ... # Ground-truth label >>> >>> class_map = ['cat', 'dog'] >>> model = DenseNet121(class_map) >>> >>> z = model(x) # Forward propagation >>> loss = model.loss(z, y) # Loss calculation >>> reg_loss = loss + model.regularize() # Add weight decay term.
-
class
DenseNet169
( class_map=None , imsize=(224 , 224) , load_pretrained_weight=False , train_whole_network=False ) ¶ -
DenseNet169モデル
もし引数load_pretrained_weightがTrueなら、事前学習済みの重みがダウンロードされます。事前学習の重みはILSVRC2012を使って学習しています.
パラメータ: - class_map -- クラス名の配列
- growth_rate ( int ) -- Growth rate of the number of filters.
- imsize ( int or tuple ) -- 入力画像サイズ
- train_whole_network ( bool ) -- True if the overal model is trained.
注釈
事前学習のデータセットは1000クラスのため、もし引数num_classが1000でなかった場合は最後のDense層はリセットされます。
参照
Gao Huang, Zhuang Liu, Laurens van der Maaten, Kilian Q. Weinberger Densely Connected Convolutional Network https://arxiv.org/pdf/1608.06993.pdf
-
build_data
( ) ¶ -
この関数はDenseNet169用の入力データとターゲットデータを作成する関数を返します。
戻り値: 入力データと出力データを作成する関数を返します。 戻り値の型: (function) 例
>>> builder = model.build_data() # This will return function. >>> x, y = builder(image_path_list, annotation_list) >>> z = model(x) >>> loss = model.loss(z, y)
-
fit
( train_img_path_list=None , train_annotation_list=None , valid_img_path_list=None , valid_annotation_list=None , epoch=136 , batch_size=64 , optimizer=None , augmentation=None , callback_end_epoch=None ) ¶ -
この関数は与えられたデータを元に学習を行います。
パラメータ: - train_img_path_list ( list ) -- クラス名の配列
- train_annotation_list ( list ) -- クラス名の配列
- valid_img_path_list ( list ) -- バリデーションの画像のパスのリスト
- valid_annotation_list ( list ) -- バリデーション用のアノテーションのリスト
- epoch ( int ) -- 学習時のエポック数
- batch_size ( int ) -- バッチサイズ
- augmentation ( Augmentation ) -- Augmentationオブジェクト
- callback_end_epoch ( function ) -- 与えらえた関数は各エポックの終了時に呼ばれます。
戻り値: 学習誤差のリストとバリデーション誤差のリスト
戻り値の型: (tuple)
例
>>> train_img_path_list, train_annot_list = ... # Define train data >>> valid_img_path_list, valid_annot_list = ... # Define validation data >>> class_map = ... # Define class map >>> model = DenseNet169(class_map) # Specify any algorithm provided by ReNomIMG API here >>> model.fit( ... # Feeds image and annotation data ... train_img_path_list, ... train_annot_list, ... valid_img_path_list, ... valid_annot_list, ... epoch=8, ... batch_size=8) >>>
以下の引数はcallback_end_epochに指定された関数に渡されます。
- epoch (int) - 現在のエポック数
- model (Model) - モデルオブジェクト
- avg_train_loss_list (list) - 各エポックの平均学習誤差のリスト
- avg_train_loss_list (list) - 各エポックの平均バリデーション誤差のリスト
-
forward
( x ) ¶ -
順伝播を実行します。この関数は__call__メソッドにより呼ぶことができます。
パラメータ: x ( ndarray , Node ) -- DenseNet169への入力 戻り値: DenseNet169の生の出力を返します。 戻り値の型: (Node) 例
>>> import numpy as np >>> x = np.random.rand(1, 3, 224, 224) >>> >>> class_map = ["dog", "cat"] >>> model = DenseNet169(class_map) >>> >>> y = model.forward(x) # Forward propagation. >>> y = model(x) # Same as above result.
-
loss
( x , y ) ¶ -
DenseNet169アルゴリズムの誤差関数
パラメータ: - x ( ndarray , Node ) -- モデルの出力
- y ( ndarray , Node ) -- ターゲット配列
戻り値: xとy間の誤差
戻り値の型: (Node)
例
>>> builder = model.build_data() # This will return a builder function. >>> x, y = builder(image_path_list, annotation_list) >>> z = model(x) >>> loss = model.loss(z, y)
-
predict
( img_list , batch_size=1 , return_scores=False ) ¶ -
予測を実行します。引数には画像の配列、画像のパスのリストもしくは画像のパスが可能です。
パラメータ: - img_list ( ndarray , list , string ) -- 画像の配列、画像のパスのリストもしくは画像のパス
- batch_size ( int ) -- 入力画像データの処理に使うバッチサイズ
- return_scores ( bool ) -- 全クラスに対する推論結果のスコア値を返すかどうかのフラグ。デフォルトはFalse。
戻り値: 各画像に対する推論結果を返します。return_scoresフラグがTrueであれば、全クラスに対する推論スコア値も返します。
戻り値の型: (array)
-
preprocess
( x ) ¶ -
与えられた配列に対して、前処理を実行します。
パラメータ: x ( ndarray , Node ) -- 前処理用の画像の配列
-
regularize
( ) ¶ -
誤差関数のL2正則化項
例
>>> x = numpy.random.rand(1, 3, 224, 224) # Input image >>> y = ... # Ground-truth label >>> >>> class_map = ['cat', 'dog'] >>> model = DenseNet169(class_map) >>> >>> z = model(x) # Forward propagation >>> loss = model.loss(z, y) # Loss calculation >>> reg_loss = loss + model.regularize() # Add weight decay term.
-
class
DenseNet201
( class_map=None , imsize=(224 , 224) , load_pretrained_weight=False , train_whole_network=False ) ¶ -
DenseNet201モデル
もし引数load_pretrained_weightがTrueなら、事前学習済みの重みがダウンロードされます。事前学習の重みはILSVRC2012を使って学習しています.
パラメータ: - class_map -- クラス名の配列
- growth_rate ( int ) -- Growth rate of the number of filters.
- load_weight ( bool ) -- True if the pre-trained weight is loaded.
- imsize ( int or tuple ) -- 入力画像サイズ
- train_whole_network ( bool ) -- True if the overal model is trained.
注釈
事前学習のデータセットは1000クラスのため、もし引数num_classが1000でなかった場合は最後のDense層はリセットされます。
参照
Gao Huang, Zhuang Liu, Laurens van der Maaten, Kilian Q. Weinberger Densely Connected Convolutional Network https://arxiv.org/pdf/1608.06993.pdf
-
build_data
( ) ¶ -
この関数はDenseNet201用の入力データと出力データを作成します。
戻り値: 入力データと出力データを作成する関数を返します。 戻り値の型: (function) 例
>>> builder = model.build_data() # This will return function. >>> x, y = builder(image_path_list, annotation_list) >>> z = model(x) >>> loss = model.loss(z, y)
-
fit
( train_img_path_list=None , train_annotation_list=None , valid_img_path_list=None , valid_annotation_list=None , epoch=136 , batch_size=64 , optimizer=None , augmentation=None , callback_end_epoch=None ) ¶ -
この関数は与えられたデータを元に学習を行います。
パラメータ: - train_img_path_list ( list ) -- クラス名の配列
- train_annotation_list ( list ) -- クラス名の配列
- valid_img_path_list ( list ) -- バリデーションの画像のパスのリスト
- valid_annotation_list ( list ) -- バリデーション用のアノテーションのリスト
- epoch ( int ) -- 学習時のエポック数
- batch_size ( int ) -- バッチサイズ
- augmentation ( Augmentation ) -- Augmentationオブジェクト
- callback_end_epoch ( function ) -- 与えらえた関数は各エポックの終了時に呼ばれます。
戻り値: 学習誤差のリストとバリデーション誤差のリスト
戻り値の型: (tuple)
例
>>> train_img_path_list, train_annot_list = ... # Define train data >>> valid_img_path_list, valid_annot_list = ... # Define validation data >>> class_map = ... # Define class map >>> model = DenseNet201(class_map) # Specify any algorithm provided by ReNomIMG API here >>> model.fit( ... # Feeds image and annotation data ... train_img_path_list, ... train_annot_list, ... valid_img_path_list, ... valid_annot_list, ... epoch=8, ... batch_size=8) >>>
以下の引数はcallback_end_epochに指定された関数に渡されます。
- epoch (int) - 現在のエポック数
- model (Model) - モデルオブジェクト
- avg_train_loss_list (list) - 各エポックの平均学習誤差のリスト
- avg_train_loss_list (list) - 各エポックの平均バリデーション誤差のリスト
-
forward
( x ) ¶ -
順伝播を実行します。この関数は__call__メソッドにより呼ぶことができます。
パラメータ: x ( ndarray , Node ) -- DenseNet201への入力 戻り値: DenseNet201の生の出力を返します。 戻り値の型: (Node) 例
>>> import numpy as np >>> x = np.random.rand(1, 3, 224, 224) >>> >>> class_map = ["dog", "cat"] >>> model = DenseNet201(class_map) >>> >>> y = model.forward(x) # Forward propagation. >>> y = model(x) # Same as above result.
-
loss
( x , y ) ¶ -
DenseNet201アルゴリズムの誤差関数
パラメータ: - x ( ndarray , Node ) -- モデルの出力
- y ( ndarray , Node ) -- ターゲット配列
戻り値: xとy間の誤差
戻り値の型: (Node)
例
>>> builder = model.build_data() # This will return a builder function. >>> x, y = builder(image_path_list, annotation_list) >>> z = model(x) >>> loss = model.loss(z, y)
-
predict
( img_list , batch_size=1 , return_scores=False ) ¶ -
予測を実行します。引数には画像の配列、画像のパスのリストもしくは画像のパスが可能です。
パラメータ: - img_list ( ndarray , list , string ) -- 画像の配列、画像のパスのリストもしくは画像のパス
- batch_size ( int ) -- 入力画像データの処理に使うバッチサイズ
- return_scores ( bool ) -- 全クラスに対する推論結果のスコア値を返すかどうかのフラグ。デフォルトはFalse。
戻り値: 各画像に対する推論結果を返します。return_scoresフラグがTrueであれば、全クラスに対する推論スコア値も返します。
戻り値の型: (array)
-
preprocess
( x ) ¶ -
与えられた配列に対して、前処理を実行します。
パラメータ: x ( ndarray , Node ) -- 前処理用の画像の配列
-
regularize
( ) ¶ -
誤差関数のL2正則化項
例
>>> x = numpy.random.rand(1, 3, 224, 224) # Input image >>> y = ... # Ground-truth label >>> >>> class_map = ['cat', 'dog'] >>> model = DenseNet201(class_map) >>> >>> z = model(x) # Forward propagation >>> loss = model.loss(z, y) # Loss calculation >>> reg_loss = loss + model.regularize() # Add weight decay term.
-
class
DenseNetC10
( class_map=None , imsize=(32 , 32) , load_pretrained_weight=False , train_whole_network=False ) ¶ -
CIFAR10データセット用のDenseNetモデル(100層)
もし引数load_pretrained_weightがTrueなら、事前学習済みの重みがダウンロードされます。事前学習の重みはCIFAR-10を使って学習しています.
パラメータ: - class_map -- クラス名の配列
- growth_rate ( int ) -- Growth rate of the number of filters.
- load_weight ( bool ) -- True if the pre-trained weight is loaded.
- imsize ( int or tuple ) -- 入力画像サイズ
- train_whole_network ( bool ) -- True if the overal model is trained.
注釈
事前学習のデータセットは1000クラスのため、もし引数num_classが1000でなかった場合は最後のDense層はリセットされます。
参照
Gao Huang, Zhuang Liu, Laurens van der Maaten, Kilian Q. Weinberger Densely Connected Convolutional Network https://arxiv.org/pdf/1608.06993.pdf
-
build_data
( ) ¶ -
この関数はDenseNetC10用の入力データと出力データを作成します。
戻り値: 入力データと出力データを作成する関数を返します。 戻り値の型: (function) 例
>>> builder = model.build_data() # This will return function. >>> x, y = builder(image_path_list, annotation_list) >>> z = model(x) >>> loss = model.loss(z, y)
-
fit
( train_img_path_list=None , train_annotation_list=None , valid_img_path_list=None , valid_annotation_list=None , epoch=136 , batch_size=64 , optimizer=None , augmentation=None , callback_end_epoch=None ) ¶ -
この関数は与えられたデータを元に学習を行います。
パラメータ: - train_img_path_list ( list ) -- クラス名の配列
- train_annotation_list ( list ) -- クラス名の配列
- valid_img_path_list ( list ) -- バリデーションの画像のパスのリスト
- valid_annotation_list ( list ) -- バリデーション用のアノテーションのリスト
- epoch ( int ) -- 学習時のエポック数
- batch_size ( int ) -- バッチサイズ
- augmentation ( Augmentation ) -- Augmentationオブジェクト
- callback_end_epoch ( function ) -- 与えらえた関数は各エポックの終了時に呼ばれます。
戻り値: 学習誤差のリストとバリデーション誤差のリスト
戻り値の型: (tuple)
例
>>> train_img_path_list, train_annot_list = ... # Define train data >>> valid_img_path_list, valid_annot_list = ... # Define validation data >>> class_map = ... # Define class map >>> model = DenseNetC10(class_map) # Specify any algorithm provided by ReNomIMG API here >>> model.fit( ... # Feeds image and annotation data ... train_img_path_list, ... train_annot_list, ... valid_img_path_list, ... valid_annot_list, ... epoch=8, ... batch_size=8) >>>
以下の引数はcallback_end_epochに指定された関数に渡されます。
- epoch (int) - 現在のエポック数
- model (Model) - モデルオブジェクト
- avg_train_loss_list (list) - 各エポックの平均学習誤差のリスト
- avg_train_loss_list (list) - 各エポックの平均バリデーション誤差のリスト
-
forward
( x ) ¶ -
順伝播を実行します。この関数は__call__メソッドにより呼ぶことができます。
パラメータ: x ( ndarray , Node ) -- DenseNetC10への入力 戻り値: DenseNetC10の生の出力を返します。 戻り値の型: (Node) 例
>>> import numpy as np >>> x = np.random.rand(1, 3, 224, 224) >>> >>> class_map = ["dog", "cat"] >>> model = DenseNetC10(class_map) >>> >>> y = model.forward(x) # Forward propagation. >>> y = model(x) # Same as above result.
-
loss
( x , y ) ¶ -
DenseNetC10アルゴリズムの誤差関数
パラメータ: - x ( ndarray , Node ) -- モデルの出力
- y ( ndarray , Node ) -- ターゲット配列
戻り値: xとy間の誤差
戻り値の型: (Node)
例
>>> builder = model.build_data() # This will return a builder function. >>> x, y = builder(image_path_list, annotation_list) >>> z = model(x) >>> loss = model.loss(z, y)
-
predict
( img_list , batch_size=1 , return_scores=False ) ¶ -
予測を実行します。引数には画像の配列、画像のパスのリストもしくは画像のパスが可能です。
パラメータ: - img_list ( ndarray , list , string ) -- 画像の配列、画像のパスのリストもしくは画像のパス
- batch_size ( int ) -- 入力画像データの処理に使うバッチサイズ
- return_scores ( bool ) -- 全クラスに対する推論結果のスコア値を返すかどうかのフラグ。デフォルトはFalse。
戻り値: 各画像に対する推論結果を返します。return_scoresフラグがTrueであれば、全クラスに対する推論スコア値も返します。
戻り値の型: (array)
-
preprocess
( x ) ¶ -
与えられた配列に対して、前処理を実行します。
パラメータ: x ( ndarray , Node ) -- 前処理用の画像の配列
-
regularize
( ) ¶ -
誤差関数のL2正則化項
例
>>> x = numpy.random.rand(1, 3, 224, 224) # Input image >>> y = ... # Ground-truth label >>> >>> class_map = ['cat', 'dog'] >>> model = DenseNetC10(class_map) >>> >>> z = model(x) # Forward propagation >>> loss = model.loss(z, y) # Loss calculation >>> reg_loss = loss + model.regularize() # Add weight decay term.