This file contains hidden or 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
import torch | |
class ResumableRandomSampler(torch.utils.data.Sampler): | |
r"""Samples elements randomly. If without replacement, then sample from a shuffled dataset. | |
If with replacement, then user can specify :attr:`num_samples` to draw. | |
Arguments: | |
data_source (Dataset): dataset to sample from | |
replacement (bool): samples are drawn on-demand with replacement if ``True``, default=``False`` | |
num_samples (int): number of samples to draw, default=`len(dataset)`. This argument | |
is supposed to be specified only when `replacement` is ``True``. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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
package com.example | |
import scala.annotation.tailrec | |
import scala.collection.immutable.Queue | |
case class TrieNode[Char, Value](values: List[Value], next: Map[Char, TrieNode[Char, Value]]) { | |
def add(str: Seq[Char], value: Value): TrieNode[Char, Value] = { | |
@tailrec | |
def addWalkDown(node: TrieNode[Char, Value], stack: List[(Char, TrieNode[Char, Value])], remaining: List[Char], value: Value): TrieNode[Char, Value] = { | |
remaining match { |