Whether to clear cache
luzai opened this issue · 2 comments
In item_recommendation, in the training process of discriminator, it seems need to clear the cache of old file, since you use linechache in ut.get_batch_data
.
for d_epoch in range(50):
if d_epoch % 5 == 0:
generate_for_d(sess, generator, DIS_TRAIN_FILE)
# whether to clear cache for old file? It seems need to add below two line code.
import linecache
linecache.clearcache()
train_size = ut.file_len(DIS_TRAIN_FILE)
index = 1
while True:
# ut.get_batch_data to generate a minibatch
# train discriminator for this minbatch
Based on linecache
documents, I think we don't need to explicitly clear cache to ensure correctness and clearcache()
is used only when you no longer need lines from files previously read using getline()
. But if there is indeed any error, any pull request is welcome.
Hi authors,
I test linecache
using some simple code in both python 2/3, finding that: If we don't use clearcache()
, dis-train.txt
will only use the sampled negatives in the first iteration. It seems the updated G will not affect D. Please let me know if I misunderstand something. Thanks!
The code snippet runs as follows:
>>> with open("test.txt", "w") as f:
... f.write("01234")
...
>>> linecache.getline('test.txt', 1)
'01234\n'
>>> with open("test.txt", "w") as f:
... f.write("56789")
...
>>> linecache.getline('test.txt', 1)
'01234\n'
>>> linecache.clearcache()
>>> linecache.getline('test.txt', 1)
'56789\n'