deep-learning

pytorch I don't know how to define multiple models

pytorch I don't know how to define multiple models Question: I want to use two different models in pytorch. Therefore, I executed the following code, but I cannot successfully run the second model. How can I do this? class Model(nn.Module): def __init__(self): super(Model, self).__init__() self.linear1 = nn.Linear(2, 64) self.linear2 = nn.Linear(64, 3) def forward(self, x): …

Total answers: 1

Shapes for training data and labels

Shapes for training data and labels Question: I am trying to train a convolutional neural network using Conv1D and sparse_categorical_crossentropy as a loss function but I keep having problems related to the shapes of the data. Here is the network: model=models.Sequential() model=tf.keras.models.Sequential([ tf.keras.layers.Conv1D(16, 24, input_shape=(1000, 4), activation="relu"), tf.keras.layers.MaxPooling1D(pool_size=24, strides=24), tf.keras.layers.Conv1D(8, 8, activation="relu"), tf.keras.layers.MaxPooling1D(pool_size=8, strides=8), tf.keras.layers.Flatten(), …

Total answers: 1

How to merge many data frames to only one

How to merge many data frames to only one Question: I have directory that has many folders inside each folder has (images folder & labels text) and I want to combine them to one dataframe file by concatnating folders name with images name to make them uinque names . The structuer of my directory like …

Total answers: 1

Deep Learning training slower on Google Cloud VM than Local PC

Deep Learning training slower on Google Cloud VM than Local PC Question: I am trying to train an LSTM neural network using Pytorch. On my own computer the process is quite slow due to the complexity of the model and size of the dataset. My initial thought was to move the training to a cloud …

Total answers: 1

Failure to install old versions of transformers in colab

Failure to install old versions of transformers in colab Question: I recently had a problem installing Transformer version 2.9.0 in colab. Asked By: hana || Source Answers: Colab has recently upgraded to Python 3.9. There is a temporary mechanism for users to run Python 3.8 runtime (Linux-5.10.147+-x86_64-with-glibc2.29 platform). This is available from the Command Palette …

Total answers: 2

predicting data bug with keras

predicting data bug with keras Question: Hi im trying to build a model in keras that can predict some data based on training values. I’ve seen this work succesfully all over the internet but my example code doesn’t work: from keras.models import Sequential from keras.layers import Dense, Activation import numpy as np model = Sequential() …

Total answers: 1

How to replace specific string in data frame column value?

How to replace specific string in data frame column value? Question: I have input.txt file that has 2 columns (file_name,text) and want to replace " " seprater charchter (which represnt tab here becuse I spreated txt file by this char) that apperar in text column example for input file : 0.jpg Jól olvasom? Összesen négy, …

Total answers: 2

How do you load a specific GPU from CUDA_AVAILABLE_DEVICES in PyTorch?

How do you load a specific GPU from CUDA_AVAILABLE_DEVICES in PyTorch? Question: I came up with this code but it’s resulting in never ending bugs: def get_device_via_env_variables(deterministic: bool = False, verbose: bool = True) -> torch.device: device: torch.device = torch.device("cpu") if torch.cuda.is_available(): if ‘CUDA_VISIBLE_DEVICES’ not in os.environ: device: torch.device = torch.device("cuda:0") else: gpu_idx: list[str] = …

Total answers: 2

Huggingface Trainer throws an AttributeError:'Namespace' object has no attribute 'get_process_log_level

Huggingface Trainer throws an AttributeError:'Namespace' object has no attribute 'get_process_log_level Question: I am trying to run Trainer from Hugging face(pytorch) with arguments parser. My code looks like if __name__ == ‘__main__’: parser = HfArgumentParser(TrainingArguments) parser.add_argument(‘–model_name_or_path’, type=str, required=True) . . . . training_args = parser.parse_args() print(‘args’, training_args) os.makedirs(training_args.output_dir, exist_ok=True) random.seed(training_args.seed) set_seed(training_args.seed) dataset_train = … . . …

Total answers: 1

How to record each fold`s validation loss during cross-validation in Optuna?

How to record each fold`s validation loss during cross-validation in Optuna? Question: I am using Toshihiko Yanase`s code for doing cross validation on my hyperparameter optimizer with Optuna. Here is the code that I am using: def objective(trial, train_loader, valid_loader): # Remove the following line. # train_loader, valid_loader = get_mnist() … return accuracy def objective_cv(trial): …

Total answers: 1