Comments (5)
Since ktrain currently allows you to use any "Adam-like" optimizer, this is already supported. Once you load a model (either by building it yourself or loading one of ktrain's pre-canned model), simply call model.compile
and supply RectifiedAdam as the optimizer. Since RectifiedAdam uses the same hyperparameters as Adam (beta_1
and beta_2
), the 1cycle and triangular learning rate policies with cyclical momentum should still work correctly.
For an example, see this Google Colab notebook that uses ktrain with Recified Adam.
from ktrain.
Does the model have to be a sequential one like in your example?
Im using a pre trained mobilenetv2 from keras and training it with radam and autofit with no problem but when i do this:
loss, acc = learner.model.evaluate_generator(learner.val_data)
i get this error:
ValueError: steps=None
is only valid for a generator based on the keras.utils.Sequence
class. Please specify steps
or use the keras.utils.Sequence
class.
So what im doing is using some values for steps(like 1 or 10) but they get differents results for final loss and final accuracy.
from ktrain.
No, the model does not have to be Sequential. It can be any Keras model.
There's a strange issue with Keras where DirectoryFrameIterator is considered an instance of Sequence in some environments (e.g., Python on Ubuntu 18.04), but not in other environments (conda Python on Google Colab, Kaggle). As a result, the steps
argument to evaluate_generator
and predict_generator
is required on Google Colab and Kaggle, but not in, say, your typical local Ubuntu 18.04 installation.
The following workaround should get learner.model.evaluate_generator
to work correctly for you (assuming your validation data is in the form of a DirectoryIterator):
learner.model.evaluate_generator(learner.val_data, steps=len(learner.val_data))
The value len(learner.val_data)
should return the number of steps or batches in the validation set. I tested the above on Google Colab and it works.
As an aside, I would also recommend upgrading ktrain to the latest version to ensure latest bug fixes are obtained.
from ktrain.
Thanks! that works
Last question: Any plan to add discriminative learning rates similar to the slice function of fast ai?
from ktrain.
Great. Adding discriminative learning rates to ktrain is under consideration. But, it's currently at a lower priority compared to other planned features, since the significance of the impact is unclear to me right now. I know that with pretrained BERT models, at least, discriminative learning rates seem to have minimal impact.
from ktrain.
Related Issues (20)
- Any plan to support T5? HOT 1
- something is wrong with the recent ktrain version HOT 9
- fixes for warnings HOT 4
- automatically use binary_accuracy instead of accuracy for multilabel problems HOT 1
- Columns and DataType Not Explicitly Set on line 30 of test_textregression.py
- is the last layer using the sigmoid as the activation when finetuning the bert model on multi-label classification task HOT 2
- deploying to huggingface HOT 16
- Topic Modeling Visualization is not working with bokeh 3.x.x HOT 3
- eli5 does not support scikit-learn>=1.3 HOT 2
- fix generative_qa imports HOT 1
- about ner tflite model HOT 1
- Bug with ktrain.text.translation HOT 7
- texts_from_df throws error AttributeError: 'NoneType' object has no attribute 'utils' HOT 2
- The initializer GlorotNormal is unseeded and being called multiple times, which will return identical values each time (even if the initializer is unseeded). HOT 3
- switch to textract-py3 HOT 1
- switch from chardet to charset-normalizer
- Unable to reload predictor : `model.compile` was created inside a different distribution strategy scope than the model HOT 1
- Is there a method to convert ktrain predictor to onnx model (optimized and quantized) without using transformers PyTorch dependencies HOT 2
- Any plans for supporting python 3.11? HOT 1
- Load model without training. 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 ktrain.