def status(self):
        docs = {'updated'  : [],
                'committed': [],
                'to_commit': []}

        row = self.db.internal.find_one({'_id': 'last_sync'})

        if row and 'update' in row:
            for id in row['update']:
                docs['updated'].append(self.get(id, deleted=True))

        if row and 'commit' in row:
            for id in row['commit']:
                docs['committed'].append(self.get(id, deleted=True))

        to_commit =  self.get_docs_to_commit()
        for row in to_commit:
            doc = Document(**row)
            docs['to_commit'].append(doc)
        return docs
def testWithoutMomentum(self, dtype):
    with self.session(use_gpu=True):
      var0 = variables.Variable([1.0, 2.0], dtype=dtype)
      var1 = variables.Variable([3.0, 4.0], dtype=dtype)
      grads0 = constant_op.constant([0.1, 0.1], dtype=dtype)
      grads1 = constant_op.constant([0.01, 0.01], dtype=dtype)
      opt = rmsprop.RMSPropOptimizer(
          learning_rate=2.0, decay=0.9, momentum=0.0, epsilon=1.0)
      update = opt.apply_gradients(zip([grads0, grads1], [var0, var1]))
      variables.global_variables_initializer().run()

      rms0 = opt.get_slot(var0, "rms")
      self.assertIsNotNone(rms0)
      rms1 = opt.get_slot(var1, "rms")
      self.assertIsNotNone(rms1)
      mom0 = opt.get_slot(var0, "momentum")
      self.assertIsNotNone(mom0)
      mom1 = opt.get_slot(var1, "momentum")
      self.assertIsNotNone(mom1)

      # Fetch params to validate initial values
      self.assertAllClose([1.0, 2.0], var0.eval())
      self.assertAllClose([3.0, 4.0], var1.eval())
      # Step 1: the rms accumulators where 1. So we should see a normal
      # update: v -= grad * learning_rate
      update.run()
      # Check the root mean square accumulators.
      self.assertAllCloseAccordingToType(
          np.array([0.901, 0.901]), rms0.eval())
      self.assertAllCloseAccordingToType(
          np.array([0.90001, 0.90001]), rms1.eval())
      # Check the parameters.
      self.assertAllCloseAccordingToType(
          np.array([
              1.0 - (0.1 * 2.0 / math.sqrt(0.901)),
              2.0 - (0.1 * 2.0 / math.sqrt(0.901))
          ]), var0.eval())
      self.assertAllCloseAccordingToType(
          np.array([
              3.0 - (0.01 * 2.0 / math.sqrt(0.90001)),
              4.0 - (0.01 * 2.0 / math.sqrt(0.90001))
          ]), var1.eval())
      # Step 2: the root mean square accumulators contain the previous update.
      update.run()
      # Check the rms accumulators.
      self.assertAllCloseAccordingToType(
          np.array([0.901 * 0.9 + 0.001, 0.901 * 0.9 + 0.001]), rms0.eval())
      self.assertAllCloseAccordingToType(
          np.array([0.90001 * 0.9 + 1e-5, 0.90001 * 0.9 + 1e-5]), rms1.eval())
      # Check the parameters.
      self.assertAllCloseAccordingToType(
          np.array([
              1.0 - (0.1 * 2.0 / math.sqrt(0.901)) -
              (0.1 * 2.0 / math.sqrt(0.901 * 0.9 + 0.001)),
              2.0 - (0.1 * 2.0 / math.sqrt(0.901)) -
              (0.1 * 2.0 / math.sqrt(0.901 * 0.9 + 0.001))
          ]), var0.eval())
      self.assertAllCloseAccordingToType(
          np.array([
              3.0 - (0.01 * 2.0 / math.sqrt(0.90001)) -
              (0.01 * 2.0 / math.sqrt(0.90001 * 0.9 + 1e-5)),
              4.0 - (0.01 * 2.0 / math.sqrt(0.90001)) -
              (0.01 * 2.0 / math.sqrt(0.90001 * 0.9 + 1e-5))
          ]), var1.eval())