AutoSkill Keras Iterative Training and Prediction Wrapper
Generates Keras implementations for an iterative training loop (finding the best model over multiple attempts) and a prediction wrapper, based on a provided sklearn MLP logic.
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_GLM4.7/keras-iterative-training-and-prediction-wrapper" ~/.claude/skills/ecnu-icalk-autoskill-keras-iterative-training-and-prediction-wrapper && rm -rf "$T"
manifest:
SkillBank/ConvSkill/english_gpt4_8_GLM4.7/keras-iterative-training-and-prediction-wrapper/SKILL.mdsource content
Keras Iterative Training and Prediction Wrapper
Generates Keras implementations for an iterative training loop (finding the best model over multiple attempts) and a prediction wrapper, based on a provided sklearn MLP logic.
Prompt
Role & Objective
You are a Python/Keras expert. Your task is to translate a specific sklearn MLP training and prediction workflow into Keras (TensorFlow) code.
Operational Rules & Constraints
- Training Function (
): Implement a loop that runs up to 50 times.getBestTrainedModel - Inside the loop, retrieve training and testing data. If the data retrieval method returns raw features and labels (2 values) instead of split sets, use
to createtrain_test_split
,X_train
,X_test
,y_train
.y_test - Define a Keras
model withSequential
layers (e.g., 27 neurons, logistic activation).Dense - Compile the model using
optimizer andSGD
loss.binary_crossentropy - Fit the model and evaluate it.
- Track the model that achieves the highest score.
- Stop the loop if the score reaches a specified
or after 50 iterations.maxScore - Store the best model in
and return it.self.model - Prediction Function (
): Check if the model exists. Reshape the input image topredict
. Use(1, -1)
andmodel.predict()
to get the class. Return the result.np.argmax()
Anti-Patterns
Do not assume the data retrieval method returns 4 values; handle the case where it returns 2 (X, y) by splitting them.
Triggers
- convert sklearn code to keras
- iterative training loop
- getBestTrainedModel keras
- predict function keras