tridu33 Learn Write a Machine learning framework:.
it is a Coursework in kaikeba .
after pip install tridu33ml,then pip listthis is a test about Boston price:
#boston.py
import numpy as np
from sklearn.datasets import load_boston
from sklearn.utils import shuffle, resample
#from miniflow import *
# Load data
data = load_boston()
X_ = data['data']
y_ = data['target']
# Normalize data
X_ = (X_ - np.mean(X_, axis=0)) / np.std(X_, axis=0)
n_features = X_.shape[1]
n_hidden = 10
W1_ = np.random.randn(n_features, n_hidden)
b1_ = np.zeros(n_hidden)
W2_ = np.random.randn(n_hidden, 1)
b2_ = np.zeros(1)
from tridu33ml.nn import core
from tridu33ml.utils import utilities
# Neural network
X, y = core.Placeholder(), core.Placeholder()
W1, b1 = core.Placeholder(), core.Placeholder()
W2, b2 = core.Placeholder(), core.Placeholder()
l1 = core.Linear(X, W1, b1)
s1 = core.Sigmoid(l1)
l2 = core.Linear(s1, W2, b2)
cost = core.MSE(y, l2)
feed_dict = {
X: X_,
y: y_,
W1: W1_,
b1: b1_,
W2: W2_,
b2: b2_
}
epochs = 5000
# Total number of examples
m = X_.shape[0]
batch_size = 16
steps_per_epoch = m // batch_size
graph = utilities.topological_sort_feed_dict(feed_dict)
trainables = [W1, b1, W2, b2]
print("Total number of examples = {}".format(m))
losses = []
for i in range(epochs):
loss = 0
for j in range(steps_per_epoch):
# Step 1
# Randomly sample a batch of examples
X_batch, y_batch = resample(X_, y_, n_samples=batch_size)
# Reset value of X and y Inputs
X.value = X_batch
y.value = y_batch
# Step 2
_ = None
utilities.forward_and_backward(graph) # set output node not important.
# Step 3
rate = 1e-2
utilities.optimize(trainables, rate)
loss += graph[-1].value
if i % 100 == 0:
print("Epoch: {}, Loss: {:.3f}".format(i+1, loss/steps_per_epoch))
losses.append(loss/steps_per_epoch)
run the test :
python boston.py
then you will see the training result.
Metadata
Release files for tridu33ml 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| tridu33ml-0.0.1.tar.gz | 6.8 kB | Without provenance | Details for tridu33ml-0.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| tridu33ml-0.0.1-py3-none-any.whl | Python 3 | none | any | Details for tridu33ml-0.0.1-py3-none-any.whl |
Total release size: 12.6 kB
Release files / tridu33ml-0.0.1.tar.gz
| Download URL | tridu33ml-0.0.1.tar.gz |
|---|---|
| Size | 6.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bccbbf20cebb113c5b5b068846a1b791a9fdb15cb611b8e35c3c8e77810d73d5
|
|
BLAKE2b-256 checksum How to use checksums |
e861a6737138bb23053cd3204a8dbaad837d4876a576585a2923bade7e6a2e35
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.6.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5
|
Release files / tridu33ml-0.0.1-py3-none-any.whl
| Download URL | tridu33ml-0.0.1-py3-none-any.whl |
|---|---|
| Size | 5.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6c4b0befc709be2860e34b0d4b3ded2f4019ffe83bb5a9666b4672db2d997737
|
|
BLAKE2b-256 checksum How to use checksums |
2eee92249dc078a8f11a7971f337d417c710af9f7c254667b832140f3fc7c54c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.6.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5
|
Security for tridu33ml 0.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.