Comments (2)
originally posted by Anton Akhmerov (@anton-akhmerov) at 2018-10-25T19:14:37.496Z on GitLab
@jorn impressive writeup and a really cool proposal!
from adaptive.
originally posted by Bas Nijholt (@basnijholt) at 2018-10-25T19:54:53.532Z on GitLab
Like we discussed already this week, this is super awesome!
I took the relevant code (notebook has a lot of NameError
s) and sped it up a bit:
from bisect import bisect_left
import adaptive
adaptive.notebook_extension()
import numpy as np
from adaptive.learner.learner1D import default_loss
from adaptive.learner.learnerND import volume
def simple_runner(learner, goal):
while not goal(learner):
x = learner.ask(1)[0][0]
y = learner.function(x)
learner.tell(x, y)
# Hack to also update the losses of neigbouring intervals
sorted_data = sorted(learner.data)
index = bisect_left(sorted_data, x)
xs = [sorted_data[i] for i in range(index-1, index+3)
if 0 <= i < len(sorted_data)]
if len(xs) > 2:
for i in range(len(xs)-1):
ival = xs[i], xs[i+1]
learner._update_interpolated_loss_in_interval(*ival)
def loss_of_multi_interval(xs, function_values):
pts = [(x, function_values[x]) for x in xs]
N = len(pts) - 2
return sum(volume(pts[i:i+3]) for i in range(N)) / N
def triangle_loss(interval, scale, function_values):
_default_loss = default_loss(interval, scale, function_values)
x_left, x_right = interval
data = sorted(function_values)
index = bisect_left(data, x_left)
xs = [data[i] for i in range(index-1, index+3) if 0 <= i < len(data)]
dx = x_right - x_left
if len(xs) <= 2:
return dx
else:
triangle_loss = loss_of_multi_interval(xs, function_values)
return triangle_loss**0.5 + 0.02 * _default_loss + 0.02 * dx
def f5(x):
return np.exp(-(x-0.3)**2/0.1**3)
learner = adaptive.Learner1D(f5, (-1, 1), loss_per_interval=triangle_loss)
simple_runner(learner, goal=lambda l: l.npoints > 1000)
learner.plot()
from adaptive.
Related Issues (20)
- Allow to choose colormap in learner2D.plot() HOT 2
- Question: plot_trisurf (matplotlib) directly from qhull HOT 3
- Incompatibility of adaptive (asyncio) with python=3.10 HOT 4
- Stop using atomic writes HOT 2
- Documentation: use cases of coroutine by Learner and Runner not properly explained HOT 2
- Rename master branch to main HOT 3
- Fix branch name (master --> main) in binder link in readme HOT 1
- No module named 'typing_extensions'" HOT 2
- Learner2D.interpolator and Learner2D.interpolated_on_grid give different results HOT 5
- Target function returns NaN HOT 5
- Use in script with BlockingRunner: get log and/or feedback on progress HOT 4
- Handling with regions unreachable inside the `ConvexHull` in `LearnerND` HOT 2
- large delay when using start_periodic_saving
- Create API for just signle process (No pickle) HOT 2
- Efficient sampling of measurment bound functions: BatchExecutor? HOT 2
- Question on uncertainty quantification HOT 2
- Issues with Multiprocess and AsyncRunner in adaptive for Phase Diagram Illustration HOT 2
- Async Running Problem with AsyncRunner HOT 2
- Normalize variabels HOT 4
- Question: is this applicable for time series?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from adaptive.