[英]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.