in lm_human_preferences/utils/core.py [0:0]
def __init__(self, *, capacity: int, schemas: Dict[str,Schema], name=None) -> None:
with tf.variable_scope(name, 'buffer', use_resource=True, initializer=tf.zeros_initializer):
self._capacity = tf.constant(capacity, dtype=tf.int32, name='capacity')
self._total = tf.get_variable(
'total', dtype=tf.int32, shape=(), trainable=False, collections=[tf.GraphKeys.LOCAL_VARIABLES],
)
self._vars = {
n: tf.get_variable(
n, dtype=s.dtype, shape=(capacity,) + s.shape, trainable=False,
collections=[tf.GraphKeys.LOCAL_VARIABLES],
)
for n,s in schemas.items()
}