I am having warning:…
- User
I am having warning: "c:\Programs\mambaforge\envs\416a3\lib\site-packages\torchinfo\torchinfo.py:477: UserWarning: TypedStorage is deprecated. It will be removed in the future and UntypedStorage will be the only storage class. This should only matter to you if you are using storages directly. To access UntypedStorage directly, use tensor.untyped_storage() instead of tensor.storage() action_fn=lambda data: sys.getsizeof(data.storage()), c:\Programs\mambaforge\envs\416a3\lib\site-packages\torch\storage.py:665: UserWarning: TypedStorage is deprecated. It will be removed in the future and UntypedStorage will be the only storage class. This should only matter to you if you are using storages directly. To access UntypedStorage directly, use tensor.untyped_storage() instead of tensor.storage() return super().sizeof() + self.nbytes()" How can I fix the warning ? I mean these are package I can not edit them so what should I do ?
- Assistant
You can try suppressing the warning with the following code:
import warnings from torchinfo import torchinfo # Suppress the TypedStorage deprecation warning warnings.filterwarnings("ignore", category=UserWarning, module="torchinfo.torchinfo") warnings.filterwarnings("ignore", category=UserWarning, module="torch.storage") # Your code that uses torchinfo # ...This code will suppress the warnings related to TypedStorage deprecation in the torchinfo module, but it won't eliminate the root cause. If you want to report the issue to the maintainers of the torchinfo package, you can open an issue on their GitHub repository: https://github.com/tyleryep/torchinfo/issues. The maintainers might fix the problem in future releases of the package.
- User
I am having error: "TypeError: default_collate: batch must contain tensors, numpy arrays, numbers, dicts or lists; found " at my code : "def run_experiments(model, learning_rates, batch_sizes, device): for lr in learning_rates: for bs in batch_sizes: train_loader = DataLoader(train_data, batch_size=bs, shuffle=True) valid_loader = DataLoader(valid_data, batch_size=bs, shuffle=False)
model = model.to(device) # choose the model you want to use criterion = nn.CrossEntropyLoss() optimizer = optim.Adam(model.parameters(), lr=lr) train_losses = [] valid_losses = [] valid_accuracies = [] for epoch in range(1, 101): train_loss = train(model, criterion, optimizer, train_loader, device) valid_loss, valid_accuracy = evaluate(model, criterion, valid_loader, device) train_losses.append(train_loss) valid_losses.append(valid_loss) valid_accuracies.append(valid_accuracy) plot(train_losses, valid_losses, valid_accuracies) - Assistant
The error you're encountering is likely due to the data type of the elements in your
train_dataandvalid_data. The DataLoader expects the data to be in the form of tensors, numpy arrays, numbers, dicts, or lists. It seems that your data is not in one of these formats.To help you further, I would need more information about how you're creating
train_dataandvalid_data. If you're using a custom dataset class, please provide the code for that class, specifically the__getitem__method. If you're using a built-in dataset from PyTorch or another library, please provide the code you used to create the datasets.In the meantime, you can check if your data is in the correct format by printing the type of the elements in
train_dataandvalid_data. For example:print(type(train_data[0])) print(type(valid_data[0]))Make sure the elements are in one of the supported formats (tensors, numpy arrays, numbers, dicts, or lists). If not, you'll need to modify your dataset class or the way you're creating the datasets to ensure the data is in the correct format.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.