Exemplo n.º 1
0
    def testOrderedDictNumpyFeedFnBatchTwoWithOneEpoch(self):
        a = np.arange(32, 37)
        b = np.arange(64, 69)
        x = {"a": a, "b": b}
        ordered_dict_x = collections.OrderedDict(
            sorted(x.items(), key=lambda t: t[0]))
        placeholders = ["index_placeholder", "a_placeholder", "b_placeholder"]
        aff = ff._OrderedDictNumpyFeedFn(placeholders,
                                         ordered_dict_x,
                                         batch_size=2,
                                         num_epochs=1)

        expected = {
            "index_placeholder": [0, 1],
            "a_placeholder": [32, 33],
            "b_placeholder": [64, 65]
        }
        actual = aff()
        self.assertEqual(expected, vals_to_list(actual))

        expected = {
            "index_placeholder": [2, 3],
            "a_placeholder": [34, 35],
            "b_placeholder": [66, 67]
        }
        actual = aff()
        self.assertEqual(expected, vals_to_list(actual))

        expected = {
            "index_placeholder": [4],
            "a_placeholder": [36],
            "b_placeholder": [68]
        }
        actual = aff()
        self.assertEqual(expected, vals_to_list(actual))
Exemplo n.º 2
0
  def testOrderedDictNumpyFeedFnLargeBatchWithSmallArrayAndMultipleEpochs(self):
    a = np.arange(32, 34)
    b = np.arange(64, 66)
    x = {"a": a, "b": b}
    ordered_dict_x = collections.OrderedDict(
        sorted(x.items(), key=lambda t: t[0]))
    placeholders = ["index_placeholder", "a_placeholder", "b_placeholder"]
    aff = ff._OrderedDictNumpyFeedFn(
        placeholders, ordered_dict_x, batch_size=100, num_epochs=2)

    expected = {
        "index_placeholder": [0, 1, 0, 1],
        "a_placeholder": [32, 33, 32, 33],
        "b_placeholder": [64, 65, 64, 65]
    }
    actual = aff()
    self.assertEqual(expected, vals_to_list(actual))