code: import sys
  sys.path.append("../")
  import input_data
  import tensorflow as tf
  import numpy as np
  from net_parser import Parser
  from network import Network
  from network_builder import NetworkBuilder
  from train import TrainTool
  from layer import *
  
  def main():
      parser = Parser('../data/alexnet.cfg')
      network_builder = NetworkBuilder("test")
      mnist = input_data.read_data_sets("F:/tf_net_parser/datasets/MNIST_data/", one_hot=True) # 读取数据
      network_builder.set_parser(parser)
      network = network_builder.build() # type: Network
      network.add_input_layer(InputLayer(tf.float32, [None, 28, 28, 1]))
      network.add_output_layer(OutputLayer())
      network.set_labels_placeholder(tf.placeholder(tf.float32, [None, 10]))
      network.connect_each_layer()
      network.set_accuracy()
      network.init_optimizer()
      train_tool = TrainTool()
      train_tool.bind_network(network)
      sess = tf.Session()
      sess.run(tf.initialize_all_variables())
      for i in range(300):
          batch = mnist.train.next_batch(100)
          feed_dict = {network.input: np.reshape(batch[0], [-1, 28, 28, 1]), network.labels: batch[1]}
          train_tool.train(sess, network.output, feed_dict=feed_dict)
          if (i+1) % 100 == 0:
              train_tool.print_accuracy(sess, feed_dict)
              train_tool.save_model_to_pb_file(sess, '../pb/alexnet-' + str(i+1) + '/' , input_data={'input': network.input}, output={'predict-result': network.output})
              # train_tool.save_ckpt_model('f:/tf_net_parser/save_model/model', sess, gloabl_step=(i+1))
  
      batch_test = mnist.test.next_batch(100)
      feed_dict = {network.input: np.reshape(batch_test[0], [100, 28, 28, 1]), network.labels: batch_test[1]}
      train_tool.print_test_accuracy(sess, feed_dict)
  if __name__ == '__main__':
      main()
apis: numpy.reshape tensorflow.initialize_all_variables tensorflow.placeholder tensorflow.Session
api_extract: [(2, 'sys.path.append', 'sys.path.append', (['"""../"""'], {}), False, 'import sys\n'), (13, 'net_parser.Parser', 'Parser', (['"""../data/alexnet.cfg"""'], {}), False, 'from net_parser import Parser\n'), (14, 'network_builder.NetworkBuilder', 'NetworkBuilder', (['"""test"""'], {}), False, 'from network_builder import NetworkBuilder\n'), (15, 'input_data.read_data_sets', 'input_data.read_data_sets', (['"""F:/tf_net_parser/datasets/MNIST_data/"""'], {'one_hot': '(True)'}), False, 'import input_data\n'), (24, 'train.TrainTool', 'TrainTool', ([], {}), False, 'from train import TrainTool\n'), (26, 'tensorflow.Session', 'tf.Session', ([], {}), True, 'import tensorflow as tf\n'), (20, 'tensorflow.placeholder', 'tf.placeholder', (['tf.float32', '[None, 10]'], {}), True, 'import tensorflow as tf\n'), (27, 'tensorflow.initialize_all_variables', 'tf.initialize_all_variables', ([], {}), True, 'import tensorflow as tf\n'), (38, 'numpy.reshape', 'np.reshape', (['batch_test[0]', '[100, 28, 28, 1]'], {}), True, 'import numpy as np\n'), (30, 'numpy.reshape', 'np.reshape', (['batch[0]', '[-1, 28, 28, 1]'], {}), True, 'import numpy as np\n')]