forked from hmsc-r/hmsc-hpc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'reduce-memory-consumption' into simplify-io-w-reduce-me…
…mory-consumption
- Loading branch information
Showing
4 changed files
with
109 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import numpy as np | ||
import tensorflow as tf | ||
|
||
|
||
def convert_to_tf(data): | ||
if isinstance(data, np.ndarray): | ||
new = tf.convert_to_tensor(data, dtype=data.dtype) | ||
elif isinstance(data, list): | ||
new = [] | ||
for value in data: | ||
new.append(convert_to_tf(value)) | ||
elif isinstance(data, dict): | ||
new = {} | ||
for key, value in data.items(): | ||
new[key] = convert_to_tf(value) | ||
else: | ||
new = data | ||
|
||
return new |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters