January 2020
Beginner to intermediate
432 pages
11h 24m
English
Execute the following steps to train a 1D CNN in PyTorch.
import yfinance as yfimport numpy as npimport osimport randomimport torchimport torch.optim as optimimport torch.nn as nnfrom torch.utils.data import (Dataset, TensorDataset, DataLoader, Subset)from collections import OrderedDictfrom chapter_10_utils import create_input_data, custom_set_seedfrom sklearn.metrics import mean_squared_errordevice = 'cuda' if torch.cuda.is_available() else 'cpu'
# dataTICKER = 'INTL'START_DATE = '2015-01-02'END_DATE = '2019-12-31'VALID_START = '2019-07-01'N_LAGS = 12# neural network BATCH_SIZE = 5N_EPOCHS = 2000
df = yf.download(TICKER, start=START_DATE, ...
Read now
Unlock full access