Skip to content

Instantly share code, notes, and snippets.

@swati210994
Last active October 29, 2020 12:56
Show Gist options
  • Select an option

  • Save swati210994/a978447eb417533fc3f389574600e215 to your computer and use it in GitHub Desktop.

Select an option

Save swati210994/a978447eb417533fc3f389574600e215 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Preparing the pickle file.....\n",
"Pickle files saved as ./data/bert_inp.pkl ./data/bert_mask.pkl ./data/bert_label.pkl\n"
]
}
],
"source": [
"print('Preparing the pickle file.....')\n",
"\n",
"pickle_inp_path='./data/bert_inp.pkl'\n",
"pickle_mask_path='./data/bert_mask.pkl'\n",
"pickle_label_path='./data/bert_label.pkl'\n",
"\n",
"pickle.dump((input_ids),open(pickle_inp_path,'wb'))\n",
"pickle.dump((attention_masks),open(pickle_mask_path,'wb'))\n",
"pickle.dump((labels),open(pickle_label_path,'wb'))\n",
"\n",
"\n",
"print('Pickle files saved as ',pickle_inp_path,pickle_mask_path,pickle_label_path)"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Loading the saved pickle files..\n",
"Input shape (5572,64) Attention mask shape (5572,64) Input label shape (5572,)\n"
]
}
],
"source": [
"print('Loading the saved pickle files..')\n",
"\n",
"input_ids=pickle.load(open(pickle_inp_path, 'rb'))\n",
"attention_masks=pickle.load(open(pickle_mask_path, 'rb'))\n",
"labels=pickle.load(open(pickle_label_path, 'rb'))\n",
"\n",
"print('Input shape {} Attention mask shape {} Input label shape {}'.format(input_ids.shape,attention_masks.shape,labels.shape))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.7"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment