code: def test_load_save(net, shape):
      with tf.Graph().as_default():
          inputs = tf.placeholder(tf.float32, [None] + list(shape))
          model = net(inputs, is_training=False)
  
          # usages with the default session
  
          with tf.Session() as sess:
              model.init()
              model.save("test.npz")
              values0 = sess.run(model.weights())
  
              sess.run(model.pretrained())
              values1 = sess.run(model.weights())
  
              for v0, v1 in zip(values0, values1):
                  assert not np.allclose(v0, v1)
  
          with tf.Session() as sess:
              model.load("test.npz")
              values2 = sess.run(model.weights())
  
              for v0, v2 in zip(values0, values2):
                  assert np.allclose(v0, v2)
  
          # usages without the default session
  
          sess = tf.Session()
  
          model.init(sess)
          model.save("test2.npz", sess)
          values0 = sess.run(model.weights())
  
          sess.run(model.pretrained())
          values1 = sess.run(model.weights())
  
          for v0, v1 in zip(values0, values1):
              assert not np.allclose(v0, v1)
  
          model.load("test2.npz", sess)
          values2 = sess.run(model.weights())
  
          for v0, v2 in zip(values0, values2):
              assert np.allclose(v0, v2)
  
          with pytest.raises(AssertionError):
              model.init()
  
          with pytest.raises(AssertionError):
              model.save("test2.npz")
  
          with pytest.raises(AssertionError):
              model.load("test2.npz")
  
          sess.close()
  
          os.remove("test.npz")
          os.remove("test2.npz")
  
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 3 for calling a global function with example usage: test_load_save(net, shape) without return types