akankshakshurai/cuda-error-resolution-analysis huggingface dataset:
TypeError: __init__() got an unexpected keyword argument 'seed'

username: A_Shamsadini
cooked: <p>Hi why I have this error?<br>
worker_info.dataset.setup_augmentor(worker_id, worker_seed)<br>
File “/content/drive/MyDrive/hover_net-master/dataloader/train_loader.py”, line 68, in setup_augmentor<br>
self.augmentor = self.__get_augmentation(self.mode, seed)<br>
File “/content/drive/MyDrive/hover_net-master/dataloader/train_loader.py”, line 134, in __get_augmentation<br>
seed=rng,<br>
TypeError: <strong>init</strong>() got an unexpected keyword argument ‘seed’</p>
<p>if mode == “train”:</p>
<pre><code>        shape_augs = [

            # * order = ``0`` -&gt; ``cv2.INTER_NEAREST``

            # * order = ``1`` -&gt; ``cv2.INTER_LINEAR``

            # * order = ``2`` -&gt; ``cv2.INTER_CUBIC``

            # * order = ``3`` -&gt; ``cv2.INTER_CUBIC``

            # * order = ``4`` -&gt; ``cv2.INTER_CUBIC``

            # ! for pannuke v0, no rotation or translation, just flip to avoid mirror padding

            #iaa.seed(rng)

            imgaug.augmenters.geometric.Affine(

                # scale images to 80-120% of their size, individually per axis

                scale={"x": (0.8, 1.2), "y": (0.8, 1.2)},

                # translate by -A to +A percent (per axis)

                translate_percent={"x": (-0.01, 0.01), "y": (-0.01, 0.01)},

                shear=(-5, 5),  # shear by -5 to +5 degrees

                rotate=(-179, 179),  # rotate by -179 to +179 degrees

                order=0,  # use nearest neighbour

                backend="cv2",  # opencv for fast processing

                seed=rng,

            ),</code></pre>

username: ptrblck
cooked: <p>I’m not deeply familiar with <code>imgaug</code>, but based on the <a href="https://github.com/aleju/imgaug/blob/0101108d4fed06bc5056c4a03e2bcb0216dac326/changelogs/v0.4.0.summary.md"><code>0.4</code> release notes</a> it seems that the arguments were renamed:</p>
<blockquote>
<ul>
<li>Reworked the standard parameters shared by all augmenters. <code>random_state</code> was renamed to <code>seed</code>, e.g. <code>Affine(..., seed=1)</code> is now valid. The parameter <code>deterministic</code> is now deprecated.</li>
</ul>
</blockquote>
<p>so I guess you might use an older release.</p>

username: A_Shamsadini
cooked: <p>That’s right<br>
Thank you so much</p>
Best way to script defaultdict(lambda: None)

username: jellybelly
cooked: <p>What is the best workaround in <strong>Torchscript (PyTorch 1.9.1)</strong> for scripting<br>
<code>cache = defaultdict(lambda: None)</code><br>
, which results in <strong>UnsupportedNodeError: Lambda aren’t supported:</strong><br>
and<br>
<code>cache = defaultdict(self.my_callable)</code><br>
, which results in  <strong>RuntimeError: method cannot be used as a value:</strong><br>
?</p>
JIT graph doesn't show fused kernels?

username: henrique
cooked: <p>For example a simple jit’ed mse:</p>
<pre><code class="lang-auto">@torch.jit.script
def jit_mse(input, target):
    return ((input - target)**2).mean()
</code></pre>
<p>shows the cuda kernel <code>fused_sub_pow</code> in the profiler, however it doesn’t change the original graph (with aten::sub and aten::pow)<br>
This seems to make the graph property a bit useless, or is this not its intended usage?<br>
Cheers</p>

username: tom
cooked: <p>The graph is the unoptimized representation, see <code>graph_for(input, target)</code> for the “full deal”. So the graph property is more “how did TorchScript understand my program” than while <code>graph_for</code> is  “what will TorchScript run”.</p>
<p>I’ve tried to summarize a bit of how that happens in a couple of articles on my blog: <a href="https://lernapparat.de/jit-optimization-intro" rel="noopener nofollow ugc">Optimizing functions in the JIT</a> and <a href="https://lernapparat.de/jit-runtime-overview/" rel="noopener nofollow ugc">Runtime overview</a>. Note that none of that is official information, so treat anything on my blog as “random person on the internet says…”.</p>
<p>Best regards</p>
<p>Thomas</p>

username: henrique
cooked: <p>Thank you for the quick reply <a class="mention" href="/u/tom">@tom</a> and also for the great articles!<br>
It looks like <code>torch.jit.last_executed_optimized_graph()</code> is what I have been looking for.<br>
Thanks</p>

username: tom
cooked: <p>Last I looked, graph_for was using that, too…</p>
what if target is None in https://github.com/pytorch/vision/blob/main/references/detection/engine.py#L27

username: vxgu86
cooked: <p>somehow that the hard negtive sample is also needed to let the network knows the net better ,but in the code</p><aside class="onebox githubblob" data-onebox-src="https://github.com/pytorch/vision/blob/main/references/detection/engine.py#L27">
  <header class="source">

      <a href="https://github.com/pytorch/vision/blob/main/references/detection/engine.py#L27" target="_blank" rel="noopener nofollow ugc">github.com</a>
  </header>

  <article class="onebox-body">
    <h4><a href="https://github.com/pytorch/vision/blob/main/references/detection/engine.py#L27" target="_blank" rel="noopener nofollow ugc">pytorch/vision/blob/main/references/detection/engine.py#L27</a></h4>



  <pre class="onebox">    <code class="lang-py">
      <ol class="start lines" start="17" style="counter-reset: li-counter 16 ;">
          <li>
          </li>
<li>lr_scheduler = None</li>
          <li>if epoch == 0:</li>
          <li>    warmup_factor = 1.0 / 1000</li>
          <li>    warmup_iters = min(1000, len(data_loader) - 1)</li>
          <li>
          </li>
<li>    lr_scheduler = torch.optim.lr_scheduler.LinearLR(</li>
          <li>        optimizer, start_factor=warmup_factor, total_iters=warmup_iters</li>
          <li>    )</li>
          <li>
          </li>
<li class="selected">for images, targets in metric_logger.log_every(data_loader, print_freq, header):</li>
          <li>    images = list(image.to(device) for image in images)</li>
          <li>    targets = [{k: v.to(device) for k, v in t.items()} for t in targets]</li>
          <li>    with torch.cuda.amp.autocast(enabled=scaler is not None):</li>
          <li>        loss_dict = model(images, targets)</li>
          <li>        losses = sum(loss for loss in loss_dict.values())</li>
          <li>
          </li>
<li>    # reduce losses over all GPUs for logging purposes</li>
          <li>    loss_dict_reduced = utils.reduce_dict(loss_dict)</li>
          <li>    losses_reduced = sum(loss for loss in loss_dict_reduced.values())</li>
          <li>
      </li>
</ol>
    </code>
  </pre>


  </article>

  <div class="onebox-metadata">
    
    
  </div>

  <div style="clear: both"></div>
</aside>
<p>
‘’‘for images, targets in metric_logger.log_every(data_loader, print_freq, header):<br>
images = list(image.to(device) for image in images)<br>
targets = [{k: v.to(device) for k, v in t.items()} for t in targets]<br>
with torch.cuda.amp.autocast(enabled=scaler is not None):<br>
loss_dict = model(images, targets)<br>
losses = sum(loss for loss in loss_dict.values())‘’’</p>
<p>it could not handle if the target is None</p>
PyTorch and "easy OCR"

username: guy675FG
cooked: <p>hello , friends<br>
i new with PyTorch<br>
my correct laptop is 2018 mac book pro  with Graphics  card of<br>
“Intel Iris Plus Graphics 655 1536 MB”<br>
when i use “easy OCR” the result are accurate but it take like 8 seconds to get the result<br>
for my project i need fast result<br>
i want to ask you : if i will buy the new mac book pro late 2021<br>
with m1 pro chips (<a href="https://www.apple.com/uk/macbook-pro-14-and-16/specs/" class="inline-onebox" rel="noopener nofollow ugc">MacBook Pro 14-inch and 16-inch - Technical Specifications - Apple (UK)</a>)<br>
will it give me fast  result in “easy OCR” ?</p>

username: guy675FG
cooked: <p>my project is to build a scrabble bot<br>
(scrabble game is playing on the screen)<br>
and the bot is player 1 and there is 3 other human player<br>
so he need in real time to recognizing and processing text on the screen</p>

username: guy675FG
cooked: <p>by the way<br>
if you asking why i use easy OCR and not tesseract<br>
that because if found in my endless trial that<br>
tesseract are fast but make a lot of mistake</p>
PyTorch Mobile - JSON model

username: angie1
cooked: <p>I have a prediction model in the json format made using pytorch. To use this model, I need to catch the features of the sound (in this case we are classifying sounds) and then use the model to classify it.</p>
<p>I have to insert this model in an app to do this classification with the sounds that the mobile catches.</p>
<p>I tried to use pytorch mobile, which uses android studio, but i understood that the uploaded model must be in .pt extension and later converted to .ptl, and mine is in .json .</p>
<p>Is it possible to just use the json model without converting it in any other format or what steps i must follow to convert the format of this model?</p>
T5tokenizer differences

username: Arij-Aladel
cooked: <p>I am not an expert here, but this question is in my mind for a while. I understand the difference between the pre-rained T5 models is the number of layers and consequently the number of parameters. But what is the difference then between the pre-trained tokenizers? I mean All models are pre-trained on c4, if the tokenizer is also trained on c4 corpus then why load the tokenizer with different names? Is the pre-trained tokenizer is the same for all models but when loading the pre-trained tokenizer we refer to the config of the pre-trained model which inside has the path to the same pre-trained tokenizer?<br>
Actually, I have tried the three tokenizers (small, base, big) to tokenize small samples of texts I did not notice any difference. Comparing the vocabulary of the three tokenizers I found that it is the same vocab for all tokenizers.<br>
Another question please and correct me if I am wrong. As to my knowledge, the tokenizer and data distribution go in parallel to train any model. If I want to pre-train the T5 model for different numbers of layers on Masked language modeling on (let us say any English text dataset from hugging face). Do I need to train the tokenizer for this corpus or it is enough to use pre trained T5 tokenizer?</p>
Can I accumulate gradients with abs()?

username: BierOne
cooked: <p>Hey, everyone!</p>
<p>Is there any way to accumulate the gradients with the abs()? I want to do some analysis using the absolute value of the gradients.</p>
<p>The following is an example:</p>
<pre><code class="lang-auto">a1_grad = torch.autograd.grad(pred[0], input, create_graph=False, retain_graph=True)[0]

a2_grad = torch.autograd.grad(pred[10], input, create_graph=False, retain_graph=True)[0]

a12_grad = torch.autograd.grad(pred[0]+pred[10], input, create_graph=False, retain_graph=True)[0]

</code></pre>
<p>My goal is to let <strong>a12_grad  == ( a1_grad.abs() + a2_grad.abs() )</strong></p>
<p>Thanks in advance!</p>
Fix random seed in training, validation and test generator

username: Kalle
cooked: <p>So I am able to fix the seeds and produce the same result everytime I run a new training. That is great. However, there are still some things I haven’t been able to answer myself.</p>
<p>My code is as follows and my questions are below the code.</p>
<pre><code class="lang-auto">seed = 1

def seed_worker(worker_id):
    import torch
    import random
    worker_seed = torch.initial_seed() % 2**32
    np.random.seed(worker_seed)
    random.seed(worker_seed)

random.seed(seed)
np.random.seed(seed)
torch.manual_seed(seed)
torch.cuda.manual_seed_all(seed)
torch.backends.cudnn.deterministic = True
torch.backends.cudnn.benchmark = False

params = {'batch_size': batch_size,
          'shuffle': shuffle,
          'num_workers': num_workers,
          'worker_init_fn': seed_worker}

training_set = Dataset(partition['train'], labels)
training_generator = torch.utils.data.DataLoader(training_set, **params)

validation_set = Dataset(partition['validation'], labels)
validation_generator = torch.utils.data.DataLoader(validation_set, **params)
</code></pre>
<ol>
<li>
<p>Is it possible to fix different seeds for each generator (training, validation)? And does it even make sense? Or do they already get different seeds?</p>
</li>
<li>
<p>In definition seed_worker, is it possible to choose a seed myself for the parameter worker_seed?</p>
</li>
<li>
<p>are some of my initializations redundant (e.g. manual_seed(…) etc.)?</p>
</li>
</ol>
JSON model on ANDROID STUDIO using PYTORCH MOBILE

username: angie1
cooked: <p>Hello,<br>
I’m using a JSON model in Android Studio, using Pytorch Mobile. From this json model i need to extract features and later regarding the values of this features classify this input as good or bad using the JSON model.</p>
<p>I was checking on the demos available for pytorch mobile. In this demos the models have always the .pt extension instead of .json. Is this problematic for me? is it possible to chargw a json model instead of a .pt model? and later, to do the lite changes, I dont do this? As we have to extract features from the input is this possible using android studio, in java?</p>