def test_one_batch(self): with self.test_session() as session: # pylint: disable=unused-variable features = [0.0, 1.0, 2.0, 3.0] labels = [10.0, 11.0, 12.0, 13.0] feature_shards, label_shards = replicate_model_fn._split_batch( features, labels, 1, device='/gpu:0') feature_shards, label_shards = self.evaluate_shards( feature_shards, label_shards) self.assertAllEqual([[0.0, 1.0, 2.0, 3.0]], feature_shards) self.assertAllEqual([[10.0, 11.0, 12.0, 13.0]], label_shards)
def test_one_batch(self): with self.test_session() as session: # pylint: disable=unused-variable features = [0.0, 1.0, 2.0, 3.0] labels = [10.0, 11.0, 12.0, 13.0] feature_shards, label_shards = replicate_model_fn._split_batch( features, labels, 1, device='/gpu:0') feature_shards, label_shards = self.evaluate_shards( feature_shards, label_shards) self.assertAllEqual([[0.0, 1.0, 2.0, 3.0]], feature_shards) self.assertAllEqual([[10.0, 11.0, 12.0, 13.0]], label_shards)
def test_one_batch_in_dictionary(self): with self.test_session() as session: # pylint: disable=unused-variable features = {'first': [0.0, 1.0, 2.0, 3.0], 'second': [4.0, 5.0, 6.0, 7.0]} labels = [10.0, 11.0, 12.0, 13.0] feature_shards, label_shards = replicate_model_fn._split_batch( features, labels, 1, device='/gpu:0') self.assertAllEqual([0.0, 1.0, 2.0, 3.0], feature_shards[0]['first'].eval()) self.assertAllEqual([4.0, 5.0, 6.0, 7.0], feature_shards[0]['second'].eval()) self.assertAllEqual([10.0, 11.0, 12.0, 13.0], label_shards[0].eval())
def test_one_batch_in_dictionary(self): with self.test_session() as session: # pylint: disable=unused-variable features = {'first': [0.0, 1.0, 2.0, 3.0], 'second': [4.0, 5.0, 6.0, 7.0]} labels = [10.0, 11.0, 12.0, 13.0] feature_shards, label_shards = replicate_model_fn._split_batch( features, labels, 1, device='/gpu:0') self.assertAllEqual([0.0, 1.0, 2.0, 3.0], feature_shards[0]['first'].eval()) self.assertAllEqual([4.0, 5.0, 6.0, 7.0], feature_shards[0]['second'].eval()) self.assertAllEqual([10.0, 11.0, 12.0, 13.0], label_shards[0].eval())