Comments (5)
originally posted by Bas Nijholt (@basnijholt) at 2018-11-19T15:24:43.030Z on GitLab
This is actually a really great way of using it.
This means that if 'fname' does not exist this method silently fails. IMO it is the caller's responsibility to catch any errors.
That doesn't happen, because this is always called.
from adaptive.
originally posted by Joseph Weston (@jbweston) at 2018-11-19T17:12:48.672Z on GitLab
This is actually a really great way of using it.
I don't understand what this means.
If I call learner.load('doesnotexistlol')
I would expect it to raise an exception and tell me that the file does not exist. Is it not confusing if your script just carries on with no data in the learner?
from adaptive.
originally posted by Joseph Weston (@jbweston) at 2018-12-07T13:55:14.137Z on GitLab
So it seems that there is a difference between what we both consider as sane behaviour.
My understanding of the arguments is as follows
Raise an exception when loading from a data file that does not exist
This makes sense because most other APIs that deal with reading files raise exceptions when the files don't exist, e.g. open()
.
If you write code that says "load some data from file X" then your expectation is that there exists a file X with loadable data
in it, and we should load this data. If any of these assumptions is false, an exception should be raised.
My opinion is that we should not make too many decisions for users. In this instance that means that we should err on the side of giving back
more information than necessary (raising an exception), rather than too little.
Silently continuing and not loading any data
This makes sense because it means that the code used in the workflow of @basnijholt can be more streamlined.
Instead of
try:
learner.load('data.txt')
except:
pass
...
we can write
learner.load('data.txt')
...
from adaptive.
originally posted by Joseph Weston (@jbweston) at 2018-12-07T13:56:30.174Z on GitLab
@jorn @anton-akhmerov opinions
from adaptive.
originally posted by Bas Nijholt (@basnijholt) at 2018-12-07T14:01:07.991Z on GitLab
The silencing is useful when running a BalancingLearner
with some parameters combinations only and then the next time adding some parameter.
like (from the documentation)
def combo_fname(learner):
val = learner.function.keywords # because functools.partial
fname = '__'.join([f'{k}_{v}.pickle' for k, v in val])
return 'data_folder/' + fname
def f(x, a, b):
return a * x**2 + b
combos = adaptive.utils.named_product(a=[1, 2], b=[1])
learners = [Learner1D(functools.partial(f, **combo), (-1, 1)) for combo in combos]
learner = BalancingLearner(learners)
runner = adaptive.Runner(learner)
learner.save(combo_fname) # use 'load' in the same way
Then you change
combos = adaptive.utils.named_product(a=[1, 2], b=[1, 2, 3])
and a part of the data will be loaded.
from adaptive.
Related Issues (20)
- make triangulation tests stronger with more randomness HOT 1
- learner tests fail HOT 2
- use a ItemSortedDict for the loss in the LearnerND
- divide by zero warnings in LearnerND
- Issues that can potentially be closed
- Improvements to plotting of the LearnerND
- Learner.load does not raise an exception if the provided filename was not found HOT 5
- Specify an API for defining the scale of point
- (LearnerND) use direct neighbours in loss
- (LearnerND) add advanced usage example HOT 1
- Document and test loss function signatures HOT 4
- Balancing learner does not work with Integrator learner HOT 5
- make triangulation tests stronger with more randomness HOT 1
- learner tests fail HOT 4
- deprecate Learner2D HOT 3
- use a ItemSortedDict for the loss in the LearnerND
- suggested points lie outside of domain HOT 2
- use a ItemSortedDict for the loss in the LearnerND
- Specify an API for defining the scale of point
- Runners should tell learner about remaining points at end of run HOT 1
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.