def testSaveLessThanRestore(self): try: self._saveAndRestore(2, 3) self.fail() except tf.errors.NotFoundError: pass def testDynamicSaveRestore(self): self._saveAndRestore(2, 2, saver_class=OptimisticRestoreSaver) def testDynamicSaveMoreThanRestore(self): self._saveAndRestore(3, 2, saver_class=OptimisticRestoreSaver) def testDynamicSaveLessThanRestore(self): self._saveAndRestore(2, 3, saver_class=OptimisticRestoreSaver) def testDynamicSaveLessThanRestoreThenSaveThenLoadNormal(self): self._saveAndRestore(2, 3, 3, saver_class=OptimisticRestoreSaver) def testDynamicSaveLessThanRestoreThenSaveThenLoadMoreNormal(self): try: self._saveAndRestore(2, 3, 4, saver_class=OptimisticRestoreSaver) self.fail() except tf.errors.NotFoundError: pass if __name__ == '__main__': # unittest.main() tftest.main()
batch_size=3, ) trajectories = [ self._make_trajectory(observations, actions) # pylint: disable=g-complex-comprehension for (observations, actions) in [ (np.array([[0, 1]]), np.array([0])), (np.array([[1, 2], [3, 4]]), np.array([0, 0])), (np.array([[1, 2], [3, 4], [5, 6]]), np.array([0, 0, 0])), ] ] metrics = simple.evaluate_model(env, trajectories, plt) self.assertIsNotNone(metrics) self.assertEqual(len(metrics), 2) def test_fails_to_evaluate_model_with_matrix_observation_space(self): with backend.use_backend('numpy'): env = self._make_env( # pylint: disable=no-value-for-parameter observation_space=gym.spaces.Box(shape=(2, 2), low=0, high=1), action_space=gym.spaces.Discrete(n=1), max_trajectory_length=2, batch_size=1, ) trajectories = [ self._make_trajectory(np.array([[0, 1], [2, 3]]), np.array([0]))] metrics = simple.evaluate_model(env, trajectories, plt) self.assertIsNone(metrics) if __name__ == '__main__': test.main()
= self._make_constant_displacement_image( u, d, floating_data) resampled_data = sess.run( warped, feed_dict={ img: floating_data\ .reshape(image_batch_shape), disp: displacement_data\ .reshape(disp_batch_shape), }) resampled_data = resampled_data.reshape( floating_shape) self._test_resampled(resampled_data, floating_data, u, code, d) def test_cpu_resampling(self): self._test_resampling(False) def test_gpu_resampling(self): if tft.is_gpu_available(cuda_only=True) and tft.is_built_with_cuda(): self._test_resampling(True) else: self.skipTest('No CUDA support available') if __name__ == '__main__': tft.main()