Tensorflow初始-v4分类图像

时间:2017-08-15 05:36:06

标签: tensorflow

我使用TF-slim inception-v4从头开始训练模型。

python train_image_classifier.py \
--train_dir=${TRAIN_DIR} \
--dataset_name=mydata \
--dataset_split_name=train \
--dataset_dir=${DATASET_DIR} \
--model_name=inception_v4 \
--clone_on_cpu=true \
--max_number_of_steps=1000 \
--log_every_n_steps=100

# Run evaluation.
python eval_image_classifier.py \
--checkpoint_path=${TRAIN_DIR} \
--eval_dir=${TRAIN_DIR} \
--dataset_name=mydata \
--dataset_split_name=validation \
--dataset_dir=${DATASET_DIR} \
--model_name=inception_v4 \
--batch_size=32

# # # Fine-tune all the new layers for 500 steps.
python train_image_classifier.py \
--train_dir=${TRAIN_DIR}/all \
--dataset_name=mydata \
--dataset_split_name=train \
--dataset_dir=${DATASET_DIR} \
--model_name=inception_v4 \
--clone_on_cpu=true \
--checkpoint_path=${TRAIN_DIR} \
--max_number_of_steps=1000 \
--log_every_n_steps=100 \
--batch_size=32 \
--learning_rate=0.0001 \
--learning_rate_decay_type=fixed \
--save_interval_secs=600 \
--save_summaries_secs=600 \
--optimizer=rmsprop \
--weight_decay=0.00004

然后冻结图表:

python export_inference_graph.py \
--alsologtostderr \
--model_name=inception_v4 \
--is_training=True \
--labels_offset=999 \
--output_file=${OUTPUT_DIR}/unfrozen_inception_v4_graph.pb \
--dataset_dir=${DATASET_DIR}

#NEWEST_CHECKPOINT=$(cat ${TRAIN_DIR}/all/checkpoint |head -n1|awk -F\" '{print $2}')
NEWEST_CHECKPOINT=$(ls -t1 ${TRAIN_DIR}/all|grep model.ckpt |head -n1)
echo ${NEWEST_CHECKPOINT%.*}
python ${OUTPUT_DIR}/tensorflow/tensorflow/python/tools/freeze_graph.py \
--input_graph=${OUTPUT_DIR}/unfrozen_inception_v4_graph.pb \
--input_checkpoint=${TRAIN_DIR}/all/${NEWEST_CHECKPOINT%.*} \
--input_binary=true \
--output_graph=${OUTPUT_DIR}/frozen_inception_v4.pb \
--output_node_names=InceptionV4/Logits/Predictions \
--input_meta_graph=True

毕竟,我得到了一个frozen_inception_v4.pb文件。

这个例子https://github.com/tensorflow/tensorflow/blob/master/tensorflow/examples/label_image/label_image.py inception_v4的输入层是什么? 有谁知道如何解决这个问题?

2 个答案:

答案 0 :(得分:0)

这取决于您使用的苗条的具体实施。查看他们定义输入的位置,看看该张量的名称是什么。

答案 1 :(得分:-1)

试试这个:

function concatAllSheets()
{
  var includedSheet=['Sheet1','Sheet2','Sheet3'];
  var ss=SpreadsheetApp.getActive();
  var allSheets=ss.getSheets();
  var sheetName='motherofallsheets-' + Utilities.formatDate(new Date(), Session.getScriptTimeZone(), "yyyyMMddHHmm")
  var mother=ss.insertSheet(sheetName);
  for(var i=0;i<allSheets.length;i++)
  {
    var sht=allSheets[i];
    if(includedSheet.indexOf(sht.getName())>-1)
    {
      var rng=sht.getDataRange();
      var rngA=rng.getValues();
      for(var j=0;j<rngA.length;j++)
      {
        var row=rngA[j];
        mother.appendRow(row);
      }
    }
  }
}

它将显示可能的输入和输出层

相关问题