ZijunLost
ZijunLost

Reputation: 1614

what is the argument "capacity" for in tf.train.string_input_producer()

The capacity argument of the function tf.train.string_input_producer(string_tensor, num_epochs=None, shuffle=True, seed=None, capacity=32, shared_name=None, name=None) is rather vague for me.

What does it mean to set the capacity argument here, does it have anything to do with the length of the argument string_tensor. An example will be wonderful. Many thanks.

Upvotes: 3

Views: 1416

Answers (2)

Salvador Dali
Salvador Dali

Reputation: 222751

Capacity for string_input_producer is the maximum number of elements that a queue can hold at any given time. You should set the number high enough so that your model will not starve from not enough data. But if you will set it too high, the queue will consume too much memory.

The best number is model-specific and you can find it by trial and error. Start with a reasonably small number and check how often your queue is empty. Increase the buffer till you will not see an empty queue.

Upvotes: 0

Yaroslav Bulatov
Yaroslav Bulatov

Reputation: 57953

Capacity is the size of the Queue, so in your example, the queue runner can enqueue up to 32 strings into the queue by default

Upvotes: 3

Related Questions