搞了几天终于把这个给搞得差不多了,遇到的错误这里也记录一下:

一、配置【配置什么的300和512其实差不多,这里只举一个例子来分析一下】

 之前的文件修改什么的和300x300的一样:https://www.cnblogs.com/GrPhoenix/p/10018072.html

从自己训练的ssd_300_vgg模型开始训练ssd_512_vgg的模型

      因ssd_300_vgg中没有block12,又因为block7,block8,block9,block10,block11,中的参数张量两个网络模型中不匹配,因此ssd_512_vgg中这几个模块的参数不从ssd_300_vgg模型中继承,因此使用checkpoint_exclude_scopes命令指出。

         因为所有的参数均需要训练,因此不使用命令--trainable_scopes

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
1 #/bin/bash
 2 DATASET_DIR=/home/data/xxx/imagedata/xing_tf/train_tf/
 3 TRAIN_DIR=/home/data/xxx/model/xing300512_model/
 4 CHECKPOINT_PATH=/home/data/xxx/model/xing300_model/model.ckpt-60000   #加载的ssd_300_vgg模型
 5 python3 ./train_ssd_network.py \
 6        --train_dir=${TRAIN_DIR} \
 7        --dataset_dir=${DATASET_DIR} \
 8        --dataset_name=pascalvoc_2007 \
 9        --dataset_split_name=train \
10        --model_name=ssd_512_vgg \
11        --checkpoint_path=${CHECKPOINT_PATH} \
12        --checkpoint_model_scope=ssd_300_vgg \
13        --checkpoint_exclude_scopes=ssd_512_vgg/block7,ssd_512_vgg/block7_box,ssd_512_vgg/block8,ssd_512_vgg/block8_box,ssd_512_vgg/block9,ssd_512_vgg/block9_box,ssd_512_vgg/block10,ssd_512_vgg/block10_box,ssd_512_vgg/block11,ssd_512_vgg/b    lock11_box,ssd_512_vgg/block12,ssd_512_vgg/block12_box \
14        #--trainable_scopes=ssd_300_vgg/conv6,ssd_300_vgg/conv7,ssd_300_vgg/block8,ssd_300_vgg/block9,ssd_300_vgg/block10,ssd_300_vgg/block11,ssd_300_vgg/block4_box,ssd_300_vgg/block7_box,ssd_300_vgg/block8_box,ssd_300_vgg/block9_box,ssd_3    00_vgg/block10_box,ssd_300_vgg/block11_box \
15        --save_summaries_secs=28800 \
16        --save_interval_secs=28800 \
17        --weight_decay=0.0005 \
18        --optimizer=adam \
19        --learning_rate_decay_factor=0.94 \
20        --batch_size=16 \
21        --num_classes=4 \
22        -gpu_memory_fraction=0.8 \

另外由300转512后还需修改:

1. 首先修改ssd_vgg_512.py的训练类别

2.修改train_ssd_network.py的model_name

   修改为ssd_512_vgg

3. 修改nets/np_methods.py

    修改:将300改为512, 将类别改为自己数据的类别(+背景)

4. 修改preprocessing/ssd_vgg_preprocessing.py

    修改:将300改为512

5. 修改ssd_notbook.ipynb

   a  将文件中数字“300”改为“512”

其他修改可以参考:http://blog.csdn.net/liuyan20062010/article/details/78905517

二、我遇到的错误:

InvalidArgumentError (see above for traceback): Restoring from checkpoint failed. This is most likely due to a mismatch between the current graph and the graph from the checkpoint. Please ensure that you have not altered the graph expected based on the checkpoint. Original error:

Assign requires shapes of both tensors to match. lhs shape= [84] rhs shape= [8]
	 [[{{node save/Assign_20}} = Assign[T=DT_FLOAT, _class=["loc:@ssd_512_vgg/block12_box/conv_cls/biases"], use_locking=true, validate_shape=true, _device="/job:localhost/replica:0/task:0/device:GPU:0"](ssd_512_vgg/block12_box/conv_cls/biases, save/RestoreV2/_41)]]
	 [[{{node save/RestoreV2/_104}} = _Send[T=DT_FLOAT, client_terminated=false, recv_device="/job:localhost/replica:0/task:0/device:GPU:0", send_device="/job:localhost/replica:0/task:0/device:CPU:0", send_device_incarnation=1, tensor_name="edge_110_save/RestoreV2", _device="/job:localhost/replica:0/task:0/device:CPU:0"](save/RestoreV2:52)]]

  这类的问题本质上来说还是自己的配置不对,这个问题我查了很久,最后发现实在是太simpleT-T。

  我的问题的话:在从300转到512的时候忘记改ssd_vgg_512.py的类别导致test的时候文件配置和训练的tensor  shape不匹配TT...