DynamicNetworkArchitectures
raw JSON → 0.4.3 verified Fri May 01 auth: no python
A library for dynamic network architectures, including Deep Belief Networks and other configurable neural network structures. Version 0.4.3 supports Python 3.8+, focuses on flexible network building and training utilities. Release cadence is irregular.
pip install dynamic-network-architectures Common errors
error TypeError: 'ZipFile' object is not callable ↓
cause Code attempts to open a .zip file using a function named 'ZipFile' conflicting with the Python standard library 'zipfile.ZipFile' after importing dynamic_network_architectures, which re-exports 'ZipFile' as a custom class.
fix
Use explicit import: from zipfile import ZipFile as ZipFileStd, or avoid importing dynamic_network_architectures after zipfile imports. Alternatively, import ZipFile directly from dynamic_network_architectures if that's intended.
error ModuleNotFoundError: No module named 'dynamic_network_architectures.models' ↓
cause Attempt to import submodules that do not exist directly under that path. The package structure is flat; models are accessible at the package root.
fix
Import classes directly from the package: from dynamic_network_architectures import DeepBeliefNetwork, not from dynamic_network_architectures.models.
error AttributeError: 'DeepBeliefNetwork' object has no attribute 'fit' ↓
cause Using an older version (<0.4.0) where the method was named 'train'. In 0.4.0+, 'fit' replaced 'train'.
fix
Update to version 0.4.0+ and use model.fit(data). If pinned to older version, use model.train(data).
Warnings
breaking In version 0.4.0, the 'layers' parameter in DeepBeliefNetwork changed from list of dicts to list of ints. Old code with dict configurations will break. ↓
fix Update to use simple integers for layer sizes, e.g., layers=[784, 500, 200].
deprecated The 'n_gibbs_steps' argument in DeepBeliefNetwork.generate() is deprecated in 0.4.3 and will be removed in next release. Use 'chain_length' instead. ↓
fix Replace n_gibbs_steps with chain_length: model.generate(n_samples, chain_length=10).
gotcha Training with mini-batches requires data to be a torch.Tensor. Passing bare numpy arrays to fit() will raise a TypeError. ↓
fix Convert numpy arrays to torch tensors before calling fit().
Imports
- DeepBeliefNetwork wrong
from dynamic_network_architectures.models import DeepBeliefNetworkcorrectfrom dynamic_network_architectures import DeepBeliefNetwork - StackedRBMs wrong
from dynamic_network_architectures.stacked_rbms import StackedRBMscorrectfrom dynamic_network_architectures import StackedRBMs
Quickstart
from dynamic_network_architectures import DeepBeliefNetwork
import torch
# Create a simple Deep Belief Network
model = DeepBeliefNetwork(
layers=[784, 500, 200],
learning_rate=0.01,
n_epochs=10,
batch_size=64
)
# Generate random data (e.g., MNIST-like)
data = torch.randn(64, 784)
# Train the model
model.fit(data)
# Generate samples
samples = model.generate(n_samples=10)
print(samples.shape)