Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/303.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/video/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何在matterport/Mask RCNN示例中减小批处理大小和图像形状?_Python_Keras - Fatal编程技术网

Python 如何在matterport/Mask RCNN示例中减小批处理大小和图像形状?

Python 如何在matterport/Mask RCNN示例中减小批处理大小和图像形状?,python,keras,Python,Keras,当我运行以下代码时,我得到以下错误 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 ste

当我运行以下代码时,我得到以下错误

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,14256]的张量和 键入float on/job:localhost/replica:0/task:0/device:GPU:0 by 分配器GPU\U 0\U bfc

在这种情况下,如何减小批处理大小和图像大小

转到您的文件并更改

 IMAGE_MIN_DIM = 800 to 400
 IMAGE_MAX_DIM = 1024 to 512


我通过使用
IMAGE\u RESIZE\u MODE=None
添加以下
GPU计数=1个图像/u每个GPU=1
来减少批大小,返回了
无效参数:不兼容的形状:[1,76100256]vs.[1,75100256]
,但当我删除该行时,其余的工作正常。错误的原因是什么?在训练中使用的图像在驱动器上没有相同的大小,您必须强制某些图像对所有图像具有特定的通用大小,从您发布的形状来看,似乎正在填充(不确定),请尝试使用“无”或“pad64”,不要忘记双引号,而且没有一个是大写的,我更新了我的答案
IMAGES_PER_GPU = 2 to 1
IMAGE_RESIZE_MODE = "square" to "none"