deepmeta
Project description
deepmeta: Deep Meta Learning
This package implements deep meta learning algorithms.
Usage Example
import numpy as np
from tensorflow.keras import layers, models
from deepmeta import MAML
# Define a deep-network model
input_shape = (28, 28, 1)
category_count = 10
model = models.Sequential([
layers.Conv2D(32, kernel_size=(3, 3), activation='relu', input_shape=input_shape),
layers.MaxPooling2D(pool_size=(2, 2)),
layers.Flatten(),
layers.Dense(128, activation='relu'),
layers.Dense(category_count, activation='softmax')
])
# Initialize MAML
maml = MAML(model, meta_lr=0.001, task_lr=0.01, inner_steps=5)
# Generate dummy data
train_sample_count = 100
test_sample_count = 50
train_features = np.random.rand(*([train_sample_count] + list(input_shape)))
train_targets = np.random.randint(0, category_count, size=(train_sample_count,))
test_features = np.random.rand(*([test_sample_count] + list(input_shape)))
test_targets = np.random.randint(0, category_count, size=(test_sample_count,))
# Split data into tasks
support_set = [(train_features[i:i+5], train_targets[i:i+5]) for i in range(0, 100, 5)]
query_set = [(test_features[i:i+5], test_targets[i:i+5]) for i in range(0, 50, 5)]
# Train MAML
for epoch in range(10):
meta_loss = maml.train_step(support_set, query_set)
print(f"epoch: {epoch}, meta loss: {meta_loss.numpy()}")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
deepmeta-0.0.1.tar.gz
(2.8 kB
view details)
Built Distribution
File details
Details for the file deepmeta-0.0.1.tar.gz
.
File metadata
- Download URL: deepmeta-0.0.1.tar.gz
- Upload date:
- Size: 2.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
d1261fd0dfe47fed6e0e6c71abf284e05af0c597f224eb4493bbcbc39c793a3b
|
|
MD5 |
2ccd301dd1f8e81e456177047f2583f1
|
|
BLAKE2b-256 |
59dd6ae1383ebe34fbde12e38e1980b910ad2232407d2c6cc503fad5ec256654
|
File details
Details for the file deepmeta-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: deepmeta-0.0.1-py3-none-any.whl
- Upload date:
- Size: 3.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
62a6898b6acf96327507b64534ee20255356b9d05ff14842f6cf7231ed4263de
|
|
MD5 |
8bf00e8ac7d8e6e07632e9329fdd3acf
|
|
BLAKE2b-256 |
446dea3054e14a85545353e441168c58e1ff0148d1c55ff6baeba930210ff8bb
|