项目作者: SeuTao

项目描述 :
A high level tensorflow lib which can convert defined tf model to caffe and other engine
高级语言: Python
项目地址: git://github.com/SeuTao/Xtensorflow.git
创建时间: 2018-04-25T02:26:31Z
项目社区:https://github.com/SeuTao/Xtensorflow

开源协议:

下载


Xtensorflow

XTensorflow

A high level tensorflow lib which can convert defined tf model to caffe and other engine;

NetWork Definition:

  1. from Xtensorflow import *
  2. input = tf.placeholder(tf.float32, [batch_size, 256])
  3. xnet = Xtensorflow(input, is_train=is_training, weight_decay=weight_decay, model_name=name)
  4. fc1 = xnet.fc_layer(0, [batch_size, 256], tf.nn.relu)
  5. fc2 = xnet.fc_layer(fc1, [batch_size, 128], tf.nn.relu)
  6. fc3 = xnet.fc_layer(fc2, [batch_size, classnum], None)
  7. output = xnet.get_network_output()

Convert to Caffemodel:

  1. xnet.create_prototxt_and_caffemodel(sess,'model.prototxt','model.caffemodel')

Predefined Model Zoo:

  1. input_imgs = tf.placeholder(tf.float32, [None, 224, 224, 3])
  2. output, xnet = Resnet50(input_imgs, None, name='resnet50')
  3. xnet_variables = tf.get_collection('xnet_varibale')
  4. init = tf.variables_initializer(xnet_variables)
  5. with tf.Session() as sess:
  6. sess.run(init)
  7. xnet.create_prototxt_and_caffemodel(sess, 'model.prototxt', 'model.caffemodel')