Skip to content

Commit

Permalink
Adjustments for dataset generation.
Browse files Browse the repository at this point in the history
  • Loading branch information
gvanhoy committed Jun 26, 2023
1 parent e84054c commit 8f781bc
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
32 changes: 19 additions & 13 deletions torchsig/datasets/synthetic.py
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ def _generate_samples(self, item: Tuple) -> np.ndarray:
min_num_blocks = 2
max_num_blocks = 16
num_blocks = np.random.randint(min_num_blocks, max_num_blocks)
for block_idx in range(num_blocks):
for _ in range(num_blocks):
block_start = np.random.uniform(0.0, 0.9)
block_dur = np.random.uniform(0.05, 1.0 - block_start)
block_start = int(block_start * zero_pad.shape[1])
Expand Down Expand Up @@ -737,23 +737,29 @@ def _generate_samples(self, item: Tuple) -> np.ndarray:
if num_subcarriers * 4 * burst_dur < self.num_iq_samples:
start_idx = np.random.randint(0, output.shape[0] - self.num_iq_samples)
else:
if original_on:
lower: int = int(
max(0, int(symbol_dur * burst_dur) - self.num_iq_samples * 0.7)
)
upper: int = int(
min(
int(symbol_dur * burst_dur),
output.shape[0] - self.num_iq_samples,
)
)
start_idx = np.random.randint(lower, upper)
elif "win" in sidelobe_suppression_method:
if "win" in sidelobe_suppression_method:
start_idx = np.random.randint(
window_len, int(symbol_dur * burst_dur) + window_len
)
else:
start_idx = np.random.randint(0, int(symbol_dur * burst_dur))
# if original_on:
# lower: int = int(
# max(0, int(symbol_dur * burst_dur) - self.num_iq_samples * 0.7)
# )
# upper: int = int(
# min(
# int(symbol_dur * burst_dur),
# output.shape[0] - self.num_iq_samples,
# )
# )
# start_idx = np.random.randint(lower, upper)
# elif "win" in sidelobe_suppression_method:
# start_idx = np.random.randint(
# window_len, int(symbol_dur * burst_dur) + window_len
# )
# else:
# start_idx = np.random.randint(0, int(symbol_dur * burst_dur))

if not self.random_data:
np.random.set_state(orig_state) # return numpy back to its previous state
Expand Down
2 changes: 1 addition & 1 deletion torchsig/utils/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class LMDBDatasetWriter(DatasetWriter):
def __init__(self, path: str, *args, **kwargs):
super(LMDBDatasetWriter, self).__init__(*args, **kwargs)
self.path = path
self.env = lmdb.Environment(path, subdir=True, map_size=int(1e12), max_dbs=2)
self.env = lmdb.Environment(path, subdir=True, map_size=int(4e12), max_dbs=2)
self.data_db = self.env.open_db(b"data")
self.label_db = self.env.open_db(b"label")

Expand Down

0 comments on commit 8f781bc

Please sign in to comment.