You can download this code by clicking the button below.
This code is now available for download.
This function generates a random matrix with a specified number of rows and columns using the torch library.
Technology Stack : PyTorch
Code Type : Function
Code Difficulty : Intermediate
import torch
import random
def generate_random_matrix(n_rows, n_cols):
"""
Generate a random matrix with given number of rows and columns using torch.
"""
return torch.rand(n_rows, n_cols)