177 lines (176 with data), 4.5 kB
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"os.chdir('../')"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"from DeepPurpose import DTI as models \n",
"from DeepPurpose import utils, dataset"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"There are two ways to load the pretrained model, the first way is to load from local model directory. \n",
"\n",
"A model directory should consist of two files: \n",
"\n",
"config.pkl that describes the configuration of the model and \n",
"model.pt, which is the model weights. \n",
"\n",
"If you use model.save(MODEL_DIR) to save the model, then, it should be good.\n",
"\n",
"The below code exemplifies suppose your model is in the 'path', then, you can load the model using path_dir parameter."
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Beginning Downloading Morgan_AAC_DAVIS Model...\n",
"Downloading finished... Beginning to extract zip file...\n",
"pretrained model Successfully Downloaded...\n"
]
}
],
"source": [
"path = utils.download_pretrained_model('Morgan_AAC_DAVIS')\n",
"net = models.model_pretrained(path_dir = path)"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'input_dim_drug': 1024,\n",
" 'input_dim_protein': 8420,\n",
" 'hidden_dim_drug': 256,\n",
" 'hidden_dim_protein': 256,\n",
" 'cls_hidden_dims': [1024, 1024, 512],\n",
" 'batch_size': 256,\n",
" 'train_epoch': 100,\n",
" 'test_every_X_epoch': 20,\n",
" 'LR': 0.001,\n",
" 'drug_encoding': 'Morgan',\n",
" 'target_encoding': 'AAC',\n",
" 'result_folder': './result/',\n",
" 'binary': False,\n",
" 'mlp_hidden_dims_drug': [1024, 256, 64],\n",
" 'mlp_hidden_dims_target': [1024, 256, 64],\n",
" 'num_workers': 0}"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"net.config"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"For models that provided by us, you can directly use the pre-designated model names. The full list is in the Github README https://github.com/kexinhuang12345/DeepPurpose/blob/master/README.md#pretrained-models"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Beginning Downloading MPNN_CNN_DAVIS Model...\n",
"Downloading finished... Beginning to extract zip file...\n",
"pretrained model Successfully Downloaded...\n"
]
},
{
"data": {
"text/plain": [
"{'input_dim_drug': 1024,\n",
" 'input_dim_protein': 8420,\n",
" 'hidden_dim_drug': 128,\n",
" 'hidden_dim_protein': 256,\n",
" 'cls_hidden_dims': [1024, 1024, 512],\n",
" 'batch_size': 128,\n",
" 'train_epoch': 100,\n",
" 'LR': 0.001,\n",
" 'drug_encoding': 'MPNN',\n",
" 'target_encoding': 'CNN',\n",
" 'result_folder': './result/',\n",
" 'binary': False,\n",
" 'mpnn_hidden_size': 128,\n",
" 'mpnn_depth': 3,\n",
" 'cnn_target_filters': [32, 64, 96],\n",
" 'cnn_target_kernels': [4, 8, 12],\n",
" 'num_workers': 0}"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"net = models.model_pretrained(model = 'MPNN_CNN_DAVIS')\n",
"net.config"
]
},
{
"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
}