[go: nahoru, domu]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to release memory or free gpu. #70

Closed
talhaanwarch opened this issue Mar 1, 2020 · 2 comments
Closed

How to release memory or free gpu. #70

talhaanwarch opened this issue Mar 1, 2020 · 2 comments

Comments

@talhaanwarch
Copy link
talhaanwarch commented Mar 1, 2020

First of all, alot of thanks for creating such an amazing repo, i wish i could find it earlier, but it does not appear in google search , luckily found it in a blog and its amazing.

I am having some issues mentioned below

How to clear gpu. for example in keras there is keras.backend.clear_session. I tried model.destroy(), but that does not work..

How labels are mapped with target name.
For example, in this notebook lables are in form of integers, and classes in the piece of code t = text.Transformer(MODEL_NAME, maxlen=500, classes=train_b.target_names) are just name. So how a particular lablel let say 0 comes to know that this is xyz class and label 1 is abc class.

How can i change the loss function.

How to get probability on test data, while using
predictor = ktrain.get_predictor(learner.model, preproc=t) y_pred=predictor.predict(x_val.tolist())

@amaiya
Copy link
Owner
amaiya commented Mar 1, 2020
  • How to free GPU memory? A: See this post on releasing GPU memory in TF2
  • How are labels mapped with target name? A: The index of the label in the list of the class labels is the integer value of the label. So, if predictor.get_classes returns ['neg', 'pos'] (i.e., classes=['neg', 'pos']), then 0=neg and 1=pos. Internally, Preprocessor instances in ktrain store the mapping between label names and label indices.
  • How can I change the loss function? A: To change the loss function, you simply call model.compile with the new loss function, as you would normally do in Keras.
  • How to get probabilities on test data? A: Invoke predictor.predict_proba instead of predictor.predict. Or, call predictor.predict method with return_proba=True as argument.

@amaiya amaiya closed this as completed Mar 1, 2020
@amaiya
Copy link
Owner
amaiya commented Mar 1, 2020

Also, in terms of the mapping between integers and class names, if the labels in the array supplied as input to Transformer.preprocess_train are in string format, the next version of ktrain (v0.10.0) will probably use LabelEncoder to transform the string values to integers. LabelEncoder currently maps integers to class names by alphabetical order:

texts = ['I like this movie.', 'I hate this movie,']
labels = ['positive', 'negative']

Running the labels through LabelEncoder will assign 0 to 'negative' and 1 to 'positive.

This is what texts_from_array presently does in the current version of ktrain (v0.9.4).

P.S. Thanks for the nice comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants