danchern97 / tda4atd Goto Github PK
View Code? Open in Web Editor NEWThis is an official repository for "Artificial Text Detection via Examining the Topology of Attention Maps" presented at EMNLP 2021 conference.
This is an official repository for "Artificial Text Detection via Examining the Topology of Attention Maps" presented at EMNLP 2021 conference.
Hi there, thanks for releasing your work.
I wanted to understand the design behind barcode generation implementation in the codebase.
queue = Queue()
number_of_splits = 2
for i, filename in enumerate(tqdm(adj_filenames, desc='Calculating barcodes')):
barcodes = defaultdict(list)
adj_matricies = np.load(filename, allow_pickle=True) # samples X
print(f"Matricies loaded from: {filename}")
ntokens = ntokens_array[i*batch_size*DUMP_SIZE : (i+1)*batch_size*DUMP_SIZE]
splitted = split_matricies_and_lengths(adj_matricies, ntokens, number_of_splits)
for matricies, ntokens in tqdm(splitted, leave=False):
p = Process(
target=subprocess_wrap,
args=(
queue,
get_only_barcodes,
(matricies, ntokens, dim, lower_bound)
)
)
p.start()
barcodes_part = queue.get() # block until putted and get barcodes from the queue
p.join() # release resources
p.close() # releasing resources of ripser
Why are barcodes calculated in this synchronous subprocess manner? As I understand it, the dataset is split into 2 (why was 2 chosen as number_of_splits?), then each half is fed into a subprocess for barcode generation iteratively. GPU memory usage is quite low (around 150MB) which makes sense as only one document is considered at a time.
Since pool.starmap
is used for other parts of calculation, is there any reason why it was not used for barcode calculation? The below code using starmap
is much faster and appears to be correct, please let me know if there's anything I'm missing. Thank you!
nworkers=10
pool = multiprocessing.Pool(nworkers)
args = [(matrices, ntokens, dim, lower_bound) for matrices, ntokens in split_matrices]
all_barcodes = pool.starmap(get_only_barcodes, args)
for barcodes_part in all_barcodes:
barcodes = unite_barcodes(barcodes, barcodes_part)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.