code: def test_clone_freeze():
      inputs = 3
      outputs = 5
  
      features = C.input_variable((inputs), np.float32)
      label = C.input_variable((outputs), np.float32)
      weights = C.parameter((inputs, outputs))
      const_weights = C.constant(weights.value)
      z = C.times(features, weights)
      c = C.times(features, const_weights)
      z_clone = z.clone("freeze")
      c_clone = c.clone("freeze")
  
      # check that z and z_clone are the same
      for p, q in zip(z.parameters, z_clone.constants):
          assert np.array_equal(p.value, q.value)
  
      # check that c and c_clone are the same
      for p, q in zip(c.constants, c_clone.constants):
          assert np.array_equal(p.value, q.value)
  
      # keep copies of the old values
      z_copies = [q.value for q in z_clone.constants]
      c_copies = [q.value for q in c_clone.constants]
  
      # update z
      trainer = C.Trainer(
          z,
          C.squared_error(z, label),
          C.sgd(z.parameters, C.learning_parameter_schedule(1.0)),
      )
      x = np.random.randn(16, 3).astype("f")
      y = np.random.randn(16, 5).astype("f")
      trainer.train_minibatch({features: x, label: y})
      # update c
      for cc in c.constants:
          cc.value = np.random.randn(*cc.value.shape).astype("f")
  
      # check that z changed
      for p, q in zip(z.parameters, z_clone.constants):
          assert not np.array_equal(p.value, q.value)
  
      # check that z_clone did not change
      for p, q in zip(z_copies, z_clone.constants):
          assert np.array_equal(p, q.value)
  
      # check that c changed
      for p, q in zip(c.constants, c_clone.constants):
          assert not np.array_equal(p.value, q.value)
  
      # check that c_clone did not change
      for p, q in zip(c_copies, c_clone.constants):
          assert np.array_equal(p, q.value)
  
file_path: CNTK/bindings/python/cntk/tests/function_test.py
imports: import pytest
  import numpy
  import cntk
label_desc: Use image node_id 5 for calling a global function with example usage: test_clone_freeze() without return types