-
Notifications
You must be signed in to change notification settings - Fork 6
set half precision for numpy arrays #87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,6 +23,7 @@ def load_chr_array(channel_data_dir, chrlist): | |
| logging.info("Loading file %s" % carray_file) | ||
| chr_array[c] = bcolz.open(rootdir=carray_file) | ||
| logging.info("Array shape: %s" % str(chr_array[c].shape)) | ||
| logging.info("Array data type: %s" % str(chr_array[c].dtype)) | ||
| return chr_array | ||
|
|
||
|
|
||
|
|
@@ -74,7 +75,7 @@ def get_windows(carrays_dir, outDir, chrom_list, win, label_file_path, mode, npz | |
| n_r = 10 ** 5 | ||
| last_t = time() | ||
| i = 1 | ||
| padding = np.zeros(shape=(padding_len, n_channels), dtype=np.float32) | ||
| padding = np.zeros(shape=(padding_len, n_channels), dtype=np.half) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this precision sufficient? I would keep the former.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From the result on the test data it seems to be sufficient, but I need to try it on the real data. |
||
| if npz_mode: | ||
| numpy_array = [] | ||
| logging.info('Creating np.arrays win1 and win2...') | ||
|
|
@@ -105,6 +106,7 @@ def get_windows(carrays_dir, outDir, chrom_list, win, label_file_path, mode, npz | |
| for i in np.arange(numpy_array.shape[2]): | ||
| logging.info("windows array: non-zero elements at index %d:%d" % | ||
| (i, np.argwhere(numpy_array[i, :] != 0).shape[0])) | ||
| numpy_array= numpy_array.astype(np.half) | ||
| np.savez(file=os.path.join(outDir, 'windows'), | ||
| data=numpy_array, | ||
| labels=labs) | ||
|
|
@@ -131,7 +133,7 @@ def main(): | |
| parser.add_argument('-p', | ||
| '--outputpath', | ||
| type=str, | ||
| default='./cnn/win25/split_reads/windows/DEL', | ||
| default='./cnn/win200/split_reads/windows/DEL', | ||
| help="Specify output path") | ||
| parser.add_argument('-l', | ||
| '--logfile', | ||
|
|
@@ -140,12 +142,12 @@ def main(): | |
| parser.add_argument('-w', | ||
| '--window', | ||
| type=int, | ||
| default=25, | ||
| default=200, | ||
| help="Specify window size") | ||
| parser.add_argument('-lb', | ||
| '--labels', | ||
| type=str, | ||
| default='./cnn/win25/split_reads/windows/DEL/labels.json.gz', | ||
| default='./cnn/win200/split_reads/windows/DEL/labels.json.gz', | ||
| help="Specify label file") | ||
| parser.add_argument('-m', | ||
| '--mode', | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,7 +32,7 @@ def get_snv_number(query_seq_list, reference_base): | |
| stop_pos = chrLen | ||
| reference_sequence = twobit.TwoBitFile(itwobit) | ||
| snv_list = ['BQ', 'SNV', 'MAPQ'] | ||
| snv_array = np.zeros(shape=(stop_pos, len(snv_list)), dtype=np.float32) | ||
| snv_array = np.zeros(shape=(stop_pos, len(snv_list)), dtype=np.half) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Btw aren't all channel values counts only? |
||
| snv_dict = {v: n for n, v in enumerate(snv_list)} | ||
|
|
||
| for pileupcolumn in bamfile.pileup(chrName, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.