Ejemplo n.º 1
0
def test_linalg_norm():
    """All that I'm asking of this test is that it doesn't error out."""
    x = cp.array([1, 2, 3])
    l2 = cp.linalg.norm(x)
Ejemplo n.º 2
0
 def loss(w, x, y):
     preds = model(w, x)
     loss_score = cp.mean(cp.power(preds.ravel() - y.ravel(), cp.array(2)))
     return loss_score
Ejemplo n.º 3
0
 def fun(x):
     return cp.array([[2 * x, x + 1], [x, x]])
Ejemplo n.º 4
0
def test_sparse_coo_matrix(eye):
    """This just has to not error out."""
    data = cp.array([1, 2, 3]).astype("float32")
    rows = cp.array([1, 2, 3]).astype("float32")
    cols = cp.array([1, 3, 4]).astype("float32")
    print(eye.shape)
Ejemplo n.º 5
0
 def fun(x):
     return cp.array(x)
Ejemplo n.º 6
0
 def fun(x):
     return cp.array([x, x])
Ejemplo n.º 7
0
 def fun(x):
     A = cp.array([x, x * 1.0, x + 2.5])
     return A + A
Ejemplo n.º 8
0
 def fun(x):
     A = cp.array([[x, x * 1.0, x + 2.5], [x**2, x, x / 2.0]])
     return A + A
Ejemplo n.º 9
0
 def fun(x):
     # return cp.array([x, x * 1.0, x + 2.5])
     return cp.array([x, x, x])
Ejemplo n.º 10
0
 def fun(x):
     return cp.array([[x, x * 1.0, x + 2.5], [x**2, x, x / 2.0]])
Ejemplo n.º 11
0
def test_simple_append_arr():
    A = cp.array([1.0, 2.0, 3.0])
    b = 4.0
    check_grads(cp.append, argnum=(0, 1))(A, b)
Ejemplo n.º 12
0
 def fun(x):
     return cp.maximum(cp.array([x, x, 0.5]),
                       cp.array([[x, 0.5, x], [x, x, 0.5]]))
Ejemplo n.º 13
0
 def fun(x):
     return cp.min(
         cp.array([[x, x, x], [x, 0.5, 0.5], [0.5, 0.5, 0.5], [x, x, 0.5]]),
         axis=0,
     )
Ejemplo n.º 14
0
 def fun(x):
     return cp.max(cp.array([[x, x], [x, 0.5]]), axis=1)
Ejemplo n.º 15
0
def test_nan_to_num():
    y = cp.array([0.0, cp.nan, cp.inf, -cp.inf])
    fun = lambda x: cp.sum(cp.sin(cp.nan_to_num(x + y)))

    x = cp.random.randn(4)
    check_grads(fun)(x)