pytorch-lightning

Why is Pytorch Lightning `validation_step` executed more oftener than defined in `val_check_interval`?

Why is Pytorch Lightning `validation_step` executed more oftener than defined in `val_check_interval`? Question: I have a dataset with 20 rows and want to have four times a Pytorch Lightning validation_step called on this dataset. I am setting my `val_check_interval=0.25`, `eval_batch_size=4` and `num_train_epochs=1` . Thats my validation_step: def validation_step(self, batch, batch_idx): print("+"* 30) What I expect …

Total answers: 1

Pytorch-Lightning ModelCheckpoint get paths of saved checkpoints

Pytorch-Lightning ModelCheckpoint get paths of saved checkpoints Question: I am using PytorchLightning and beside others a ModelCheckpoint which saves models with a formated filename like filename="model_{epoch}-{val_acc:.2f}" In a process I want to load these checkpoints again, for simplicity lets say I want only the best via save_top_k=N. As the filename is dynamic I wonder how …

Total answers: 1

How to get activation values of a layer in pytorch

How to get activation values of a layer in pytorch Question: I have a pytorch-lightning model that has a dense layer like so: def __init__(…) … self.dense = nn.Linear(channels[-1], 64, bias=True) … for my project, I need to get the activation values of this layer as a list I have tried this code which I …

Total answers: 1

TypeError: unsupported operand type(s) for /: 'SequenceClassifierOutput' and 'int'

TypeError: unsupported operand type(s) for /: 'SequenceClassifierOutput' and 'int' Question: I am using hugginface library to train a bert model on classification problem. model = BertForSequenceClassification.from_pretrained(‘bert-base-uncased’, num_labels=10) def training_step(self, batch, batch_nb): sequence, label = batch input_ids, attention_mask, labels = self.prepare_batch(sequence=sequence, label=label) loss = self.model(input_ids=input_ids, attention_mask=attention_mask, labels=labels) tensorboard_logs = {‘train_loss’: loss} I am getting the following …

Total answers: 1

When I run the code, it stops when the sanity check dataloader, but no error is prompted

When I run the code, it stops when the sanity check dataloader, but no error is prompted Question: Through debugging, I found that the problem occurred when I ran to the line of trainer. fit (model).It seems that there are some problems when loading data. Here’s my code WEIGHT = "bert-base-uncased" class Classifier(pl.LightningModule): def __init__(self, …

Total answers: 1

PytorchLightning : Model calls order

PytorchLightning : Model calls order Question: I’m trying to reimplement a training pipeline on top of pytorch Lightning. In the documentation they explain that training/validation loops are executed this way : My understanding was that the order was : train_step() train_epoch_end() val_step() val_epoch_end() I’ve implemented a dummy code in order to check this : import …

Total answers: 2

Python – Torchmetric SSIM depends on batch size

Python – Torchmetric SSIM depends on batch size Question: sry for the quick question, I just want to know wether I found a bug or if I do not understand something here. I got the following sample, where I print the ssim of the torchmetrics library of two tensors with the batchsize 8 and the …

Total answers: 2

Docker Image for Image prediction using Pytorch Image Models (timm)

Docker Image for Image prediction using Pytorch Image Models (timm) Question: I want to create a docker image for Image Prediction using Timm which gives outputs in JSON format like {"predicted": "cat", "confidence": "0.99"}. I am using this code. from __future__ import print_function import argparse import torch import timm import urllib import json import torchvision.io …

Total answers: 1

Conda is installing a very old version of pytorch-lightning

Conda is installing a very old version of pytorch-lightning Question: I tried installing pytorch lightning by runnning: conda install -c conda-forge pytorch-lightning as described here: https://anaconda.org/conda-forge/pytorch-lightning This link seems updated to version 1.6.5 However, when I run this command, an old version of pytorch-lightning is installed, as can be seen here: > The following NEW …

Total answers: 2