コード例 #1
0
ファイル: test_misc.py プロジェクト: liuhanyao98/nums-1
def test_explicit_init():
    import nums
    import nums.core.application_manager as am

    nums.init()
    assert am.is_initialized()
    am.destroy()
コード例 #2
0
import nums
import nums.numpy as nps
from nums.models.glms import LogisticRegression

nums.init()

# Make dataset.

X1 = nps.random.randn(500, 1) + 5.0
y1 = nps.zeros(shape=(500, ), dtype=bool)

X2 = nps.random.randn(500, 1) + 10.0
y2 = nps.ones(shape=(500, ), dtype=bool)

X = nps.concatenate([X1, X2], axis=0)
y = nps.concatenate([y1, y2], axis=0)

# Train Logistic Regression Model.

model = LogisticRegression(solver="newton", tol=1e-8, max_iter=1)

model.fit(X, y)
y_pred = model.predict(X)

print("accuracy", (nps.sum(y == y_pred) / X.shape[0]).get())
コード例 #3
0
ファイル: example.py プロジェクト: Priyansdesai/nums
import ray
import nums
import nums.numpy as nps

# Initialize ray and connect it to the cluster.
ray.init(address="auto")
# Initialize nums with the cluster shape. Here we set it to use all the nodes in the ray cluster.
nums.init(cluster_shape=(len(ray.nodes()), 1))


def main():
    X = nps.random.rand(10**4)
    Y = nps.random.rand(10**4)
    Z = nps.add(X, Y)
    print("X + Y = ", Z.get())


if __name__ == "__main__":
    main()