簡體   English   中英

如何在matterport/Mask_RCNN 示例中減少batch_size 和image_shape?

[英]How can I reduce the batch_size and the image_shape in the matterport/Mask_RCNN example?

當我運行以下代碼時,出現以下錯誤

from mrcnn.config import Config

class KangarooConfig(Config):
    # define the name of the configuration
    NAME = "kangaroo_cfg"
    # number of classes (background + kangaroo)
    NUM_CLASSES = 1 + 1
    # number of training steps per epoch
    STEPS_PER_EPOCH = 131


from mrcnn.model import MaskRCNN

# prepare config
config = KangarooConfig()
config.display()
# define the model
model = MaskRCNN(mode='training', model_dir='./', config=config)
model.keras_model.metrics_tensors = []


# load weights (mscoco) and exclude the output layers
model.load_weights('mask_rcnn_coco.h5', by_name=True, exclude=["mrcnn_class_logits", "mrcnn_bbox_fc",  "mrcnn_bbox", "mrcnn_mask"] )
# train weights (output layers or 'heads')
model.train(train_set, test_set, learning_rate=config.LEARNING_RATE, epochs=5, layers='heads' )

錯誤:

ResourceExhaustedError: 發現 2 個根錯誤。 (0) 資源耗盡:當分配形狀為[400,14,14,256]的張量並通過分配器GPU_0_bfc在/job:localhost/replica:0/task:0/device:GPU:0上輸入float時OOM

在這種情況下,如何減少batch_size 和image_size?

代碼輸出

轉到您的Config.py文件並更改

 IMAGE_MIN_DIM = 800 to 400
 IMAGE_MAX_DIM = 1024 to 512

IMAGES_PER_GPU = 2 to 1
IMAGE_RESIZE_MODE = "square" to "none"

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM