Esempio n. 1
0
  def testMat2dToFullyConnectedLayerParamsTensor(self):
    with tf.Graph().as_default(), self.test_session() as sess:
      tf.set_random_seed(200)
      vector_template = self._fully_connected_layer_params()[0]
      mat2d = tf.constant([[5., 4.], [3., 2.]])

      output = sess.run(utils.mat2d_to_layer_params(vector_template, mat2d))

      self.assertAllClose(output, np.array([[5., 4.], [3., 2.]]))
Esempio n. 2
0
  def testMat2dToFullyConnectedLayerParamsTuple(self):
    with tf.Graph().as_default(), self.test_session() as sess:
      tf.set_random_seed(200)
      vector_template = self._fully_connected_layer_params()
      mat2d = tf.constant([[5., 4.], [3., 2.], [1., 0.]])

      output = sess.run(utils.mat2d_to_layer_params(vector_template, mat2d))

      self.assertIsInstance(output, tuple)
      self.assertEqual(len(output), 2)
      a, b = output
      self.assertAllClose(a, np.array([[5., 4.], [3., 2.]]))
      self.assertAllClose(b, np.array([1., 0.]))