%%writefile data_preparation/v0.py device = 'cuda' if torch.cuda.is_available() else 'cpu' # Our data was in Numpy arrays, but we need to transform them # into PyTorch's Tensors and then we send them to the chosen device x_train_tensor = torch.as_tensor(x_train).float().to(device) y_train_tensor = torch.as_tensor(y_train).float().to(device)
FileNotFoundError: [Errno 2] No such file or directory: 'data_preparation/v0.py'
The directory in the file path must exist.
# Derectory data_preparation must exist %%writefile data_preparation/v0.py device = 'cuda' if torch.cuda.is_available() else 'cpu' # Our data was in Numpy arrays, but we need to transform them # into PyTorch's Tensors and then we send them to the chosen device x_train_tensor = torch.as_tensor(x_train).float().to(device) y_train_tensor = torch.as_tensor(y_train).float().to(device)
UsageError: Line magic function `%%writefile` not found.
The magic function line must be the cell's first line.
%%writefile data_preparation/v0.py device = 'cuda' if torch.cuda.is_available() else 'cpu' # Our data was in Numpy arrays, but we need to transform them # into PyTorch's Tensors and then we send them to the chosen device x_train_tensor = torch.as_tensor(x_train).float().to(device) y_train_tensor = torch.as_tensor(y_train).float().to(device)
Writing data_preparation/v0.py
(zpytorch) zzh@ZZHPC:~/zd/Github/pytorchsbs/data_preparation$ cat v0.py device = 'cuda' if torch.cuda.is_available() else 'cpu' # Our data was in Numpy arrays, but we need to transform them # into PyTorch's Tensors and then we send them to the chosen device x_train_tensor = torch.as_tensor(x_train).float().to(device) y_train_tensor = torch.as_tensor(y_train).float().to(device)
%run -i data_preparation/v0.py