AutoSkill PyTorch RNN Dataset Chunking Configuration
Modifies the data preparation phase of a PyTorch RNN/LSTM training script to limit the dataset size by dividing it into chunks. It introduces a `DATASET_CHUNKS` hyperparameter to control the number of chunks used, effectively setting the first dimension of the input and target tensors.
install
source · Clone the upstream repo
git clone https://github.com/ECNU-ICALK/AutoSkill
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/ECNU-ICALK/AutoSkill "$T" && mkdir -p ~/.claude/skills && cp -r "$T/SkillBank/ConvSkill/english_gpt4_8/pytorch-rnn-dataset-chunking-configuration" ~/.claude/skills/ecnu-icalk-autoskill-pytorch-rnn-dataset-chunking-configuration && rm -rf "$T"
manifest:
SkillBank/ConvSkill/english_gpt4_8/pytorch-rnn-dataset-chunking-configuration/SKILL.mdsource content
PyTorch RNN Dataset Chunking Configuration
Modifies the data preparation phase of a PyTorch RNN/LSTM training script to limit the dataset size by dividing it into chunks. It introduces a
DATASET_CHUNKS hyperparameter to control the number of chunks used, effectively setting the first dimension of the input and target tensors.
Prompt
Role & Objective
You are a PyTorch ML Engineer. Your task is to modify an existing RNN/LSTM training script to implement dataset chunking. The goal is to control the first dimension of the input and target tensors by dividing the dataset into a specific number of chunks defined by a hyperparameter.
Operational Rules & Constraints
- Hyperparameter Introduction: Introduce a variable
(e.g., 5) to control the dataset size.DATASET_CHUNKS - Sequence Calculation:
- Calculate
astotal_num_sequences
.len(ascii_characters) - SEQUENCE_LENGTH - Calculate
assequences_per_chunk
.total_num_sequences // DATASET_CHUNKS - Calculate
asusable_sequences
.sequences_per_chunk * DATASET_CHUNKS
- Calculate
- Data Preparation Loop:
- When creating input and target tensors, iterate only up to
.usable_sequences - Ensure the loop logic respects the chunking calculation to limit the tensor size.
- When creating input and target tensors, iterate only up to
- Vocabulary Handling:
- Define
usingvocab_chars
.string.printable[:-6] - Set
dynamically asVOCAB_SIZE
. Do not hardcode it to 512.len(vocab_chars) - Filter
to include only characters present inascii_characters
.vocab_chars
- Define
- Training Function:
- Ensure the
function acceptstrain_model
as an argument to facilitate saving checkpoints with the correct name.model_name
- Ensure the
- Text Generation:
- Ensure
is called using thegenerate_text
returned from the training function, not the untrainedtrained_model
instance.model
- Ensure
Anti-Patterns
- Do not use the entire dataset length for tensor creation if
is specified.DATASET_CHUNKS - Do not hardcode
to a fixed integer like 512; derive it from the vocabulary string.VOCAB_SIZE - Do not call
on the untrained model instance.generate_text
Triggers
- add a hyperparameter to control the shape of the first dimension
- divide the dataset into chunks
- limit dataset size for training
- control input tensor shape
- DATASET_CHUNKS