Skip to content

Commit

Permalink
Sampling edge case fix (#100)
Browse files Browse the repository at this point in the history
* fixing off-by-1 edgecase in random image sampling

* bump version

---------

Co-authored-by: benliang99 <[email protected]>
  • Loading branch information
dylanuys and benliang99 authored Nov 12, 2024
1 parent be25218 commit 5ccd9ca
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion bitmind/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# DEALINGS IN THE SOFTWARE.


__version__ = "1.2.5"
__version__ = "1.2.6"
version_split = __version__.split(".")
__spec_version__ = (
(1000 * int(version_split[0]))
Expand Down
4 changes: 2 additions & 2 deletions bitmind/validator/forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def sample_random_real_image(datasets, total_images, retries=10):

def sample_real_image(datasets, index):
cumulative_sizes = np.cumsum([len(ds) for ds in datasets])
source_index = np.searchsorted(cumulative_sizes, index % (cumulative_sizes[-1]))
source_index = np.searchsorted(cumulative_sizes - 1, index % (cumulative_sizes[-1]))
source = datasets[source_index]
valid_index = index - (cumulative_sizes[source_index - 1] if source_index > 0 else 0)
return source, valid_index
Expand Down Expand Up @@ -191,4 +191,4 @@ async def forward(self):
# Logging specific prediction details
if pred != -1:
bt.logging.info(f'Miner uid: {miner_uids[i]} | prediction: {pred} | correct: {np.round(pred) == label} | reward: {rewards[i]}')
self.last_responding_miner_uids.append(miner_uids[i])
self.last_responding_miner_uids.append(miner_uids[i])

0 comments on commit 5ccd9ca

Please sign in to comment.