This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def install_pdb_handler(): | |
| """Signals to automatically start pdb: | |
| 1. CTRL+\\ breaks into pdb. | |
| 2. pdb gets launched on exception. | |
| """ | |
| import signal | |
| import pdb | |
| def handler(_signum, _frame): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from sklearn.feature_extraction.text import TfidfVectorizer | |
| from sklearn.metrics.pairwise import linear_kernel | |
| from nltk import word_tokenize | |
| from nltk.stem import WordNetLemmatizer | |
| import nltk | |
| from nltk.corpus import stopwords | |
| # Download stopwords list | |
| nltk.download('punkt') | |
| stop_words = set(stopwords.words('english')) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from flask import Flask | |
| from flask_restful import Resource, Api, reqparse | |
| import pandas as pd | |
| import ast | |
| app = Flask(__name__) | |
| api = Api(app) | |
| class Users(Resource): | |
| def get(self): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Ideally, we would manage async access to stdin/stdout/stderr *without* | |
| # setting them to non-blocking mode, because that can break other processes. | |
| # (See https://github.com/python-trio/trio/issues/174 for much more detail.) | |
| # Of course we can call read/write in a separate thread, but then we lose | |
| # cancellation support. | |
| # This file demonstrates a weird hack to make blocking read/write cancellable, | |
| # and thus at least theoretically possible to integrate into Trio as ordinary | |
| # first-class operations. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import numpy as np | |
| import torch | |
| import torch.nn as nn | |
| import onnx | |
| import onnxruntime | |
| ##### INIT 1d, 2d, 3d GLOBAL POOLING MODULES ##### |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| Example of using sub-parser, sub-commands and sub-sub-commands :-) | |
| """ | |
| import argparse | |
| def main(args): | |
| """ | |
| Just do something |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| In a binary classification problem, a neural network usually returns a vector of logits of shape [batch_size], | |
| while in a multiclass classification problem, logits are represented as a matrix of shape [batch_size, n_classes]. | |
| For these tasks, different loss functions are used, and, therefore, the network training pipelines are also different, | |
| which is not convenient when you need to test hypotheses for both problem statements (binary/multiclass). | |
| Pipeline schemes: | |
| - binary classification: | |
| logits (of shape [batch_size]) -> BCEWithLogitsLoss |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import torch | |
| import random | |
| import numpy as np | |
| def set_global_seed(seed: int): | |
| """ | |
| Set global seed for reproducibility. | |
| """ |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.