michaelnowotny / cocos Goto Github PK
View Code? Open in Web Editor NEWNumeric and scientific computing on GPUs for Python with a NumPy-like API
License: MIT License
Numeric and scientific computing on GPUs for Python with a NumPy-like API
License: MIT License
Hiya,
Thanks for writing cocos! It seems to be just what I was looking for, as I want to compute a bunch of large expressions on my GPU!
The documentation for lambdifying was a bit confusing, so I thought I'd ask here. Specifically, the readme.md refers to the LambdifiedMatrixExpression
function. It takes the following four arguments:
argument_symbols=argument_symbols,
time_symbol=t,
symbolic_matrix_expression=jacobian_f,
symbolic_time_function_name_to_numeric_time_function_map={'g': numeric_time_function})
I'm happy with the argument_symbols
and symbolic_matrix_expression
, these seem to be equivalent to the args
and expr
arguments that sp.lambdify takes. I have no idea what the other two mean. Could you expand on them?
The following code is a slight simplification of my problem. The following generates a summed spectrum of ten Gaussians with parameters stored in 1D arrays. In addition to this, there is the x
variable, which is a 1D array of a different length (100 in the example). With reference to the cocos lambdify docs, I could perhaps guess that the gaussian parameters are the "argument symbols", and x
is the "time_symbol
". But for my real problem, I am computing 2D Gaussians, and have two such variables, x
and y
, which are themselves 2D arrays containing the coordinates to evaluate the expression at. The time_symbol
argument hints at only one variable, not two, so I am a bit confused.
At this point I decided to post here, in case you could shed some light on what I should do.
import sympy as sp
import matplotlib.pyplot as plt
import numpy as np
def Gaussian(x, a, xc, sigma):
return a*sp.exp(-((x-xc)**2)/(2*sigma**2))
x, i, n = sp.symbols('x i n') # x is our main independent variable. i and n are indices
a, xc, sigma = sp.symbols('A xc sigma', cls=sp.IndexedBase) # parameters that are held in arrays
symbols = (x, a, xc, sigma, n)
Gauss = Gaussian(x, a[i], xc[i], sigma[i])
model = sp.Sum(Gauss, (i, 0, n-1)) # Sum over the parameters from (i=0 to i=n)
func = sp.lambdify(symbols, model, modules = 'numpy')
X = np.arange(100)
N = 10
A, XC, SIGMA = np.random.random((3, N))*100
y = func(X, A, XC, SIGMA, N)
plt.figure()
plt.plot(y)
I guess this is not much of an actual issue (except maybe it could result in an added paragraph in the README!), but I didn't see any better place of asking this. How does cocos
relate to the cupy
project? Are there any major paradigm or performance differences?
Hi, I'm getting an error when I run the following line in the python interpreter or if it is run within a script:
import cocos.numerics as cn
This returns the following:
Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/cocos/numerics/__init__.py", line 4, in <module> import cocos.numerics.random as random AttributeError: module 'cocos' has no attribute 'numerics'
I'm using a Mac (OS X Catalina 10.15.4)
cd.info() does work:
Cocos running on ArrayFire v3.6.4 (OpenCL 64bit) [0] Apple: Intel(R) Iris(TM) Plus Graphics 640 | OpenCL | compute version 1.2
Thanks
Mike
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.