code: def test_classification_basics(net, shape, weights, outputs, middles):
      with tf.Graph().as_default():
          inputs = tf.placeholder(tf.float32, [None] + list(shape))
          model = net(inputs, is_training=False)
          assert isinstance(model, tf.Tensor)
  
          x = np.random.random((1,) + shape).astype(np.float32) * 255
  
          with tf.Session() as sess:
              model.init()
              y = model.eval({inputs: model.preprocess(x)})
  
          assert y.shape == (1, 1000)
  
          # Check whether the tensor names match the desired ones
          assert "probs" in model.name  # for `model`
          assert "logits" in model.logits.name  # for `model.logits`
          model_name = model.aliases[0]
          for a, b in zip(
              model.get_middles(), middle_names(model_name)[1]
          ):
              assert a.name.endswith(b)  # for `model.get_middles()`
  
          # Disable the following tests for TF==1.1.0
          if LooseVersion(tf.__version__) == LooseVersion("1.1.0"):
              return
  
          # Check whether the desired list is returned
          assert len(model.get_weights()) == weights
          assert len(model.get_outputs()) == outputs
          assert len(model.get_middles()) == middles
  
      # Clear GraphDef to avoid `GraphDef cannot be larger than 2GB`
      with tf.Graph().as_default():
          inputs = tf.placeholder(tf.float32, [None] + list(shape))
  
          # Check whether the desired list is returned under scope functions
          with tf.name_scope("a"):
              with tf.variable_scope("b"):
                  with tf.name_scope("c"):
                      model = net(inputs, is_training=False)
                      assert len(model.get_weights()) == weights
                      assert len(model.get_outputs()) == outputs
                      assert len(model.get_middles()) == middles
  
          with tf.variable_scope("d"):
              with tf.name_scope("e"):
                  with tf.variable_scope("f"):
                      model = net(inputs, is_training=False)
                      assert len(model.get_weights()) == weights
                      assert len(model.get_outputs()) == outputs
                      assert len(model.get_middles()) == middles
  
file_path: tensornets/tests/basics_test.py
imports: from __future__ import absolute_import
  import numpy
  import tensorflow
  import tensornets
  import os
  import pytest
  import random
  from tensornets.middles import direct
  from distutils.version import LooseVersion
label_desc: Use image node_id 1 for calling a global function with example usage: test_classification_basics(net, shape, weights, outputs, middles) without return types