This file contains 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 multilabel_categorical_crossentropy_with_mask(y_true, y_pred): | |
"""多标签分类的交叉熵 | |
y_true 因为 0., 1. 以及-1.的array, -1. 代表mask | |
说明:y_true和y_pred的shape一致,y_true的元素非0即1, | |
1表示对应的类为目标类,0表示对应的类为非目标类。 | |
https://spaces.ac.cn/archives/7359/comment-page-2 | |
""" | |
y_mask_1 = K.cast(K.greater_equal(y_true, 0.), K.floatx()) | |
y_mask_2 = K.cast(K.less(y_true, 0.), K.floatx()) * (-1e12) | |
y_true_signed = 1 - 2 * y_true |
This file contains 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
""" | |
Module implementing an enhanced string column type for SQLAlchemy | |
with a support for regular expression operators in Postgres and SQLite. | |
""" | |
import re | |
from sqlalchemy import String as _String, event, exc | |
from sqlalchemy.engine import Engine | |
from sqlalchemy.ext.compiler import compiles | |
from sqlalchemy.sql.expression import BinaryExpression, func, literal |
This file contains 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 tqdm import tqdm | |
tqdm.pandas() | |
import os | |
os.environ["TF_KERAS"] = "1" | |
from sklearn.model_selection import train_test_split | |
import tensorflow as tf | |
import tensorflow.keras.backend as K | |
from tensorflow.keras.layers import * |
This file contains 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
Python 3.7.6 (default, Jan 8 2020, 20:23:39) [MSC v.1916 64 bit (AMD64)] | |
Type 'copyright', 'credits' or 'license' for more information | |
IPython 7.13.0 -- An enhanced Interactive Python. Type '?' for help. | |
PyDev console: using IPython 7.13.0 | |
Python 3.7.6 (default, Jan 8 2020, 20:23:39) [MSC v.1916 64 bit (AMD64)] on win32 | |
import pandas as pd | |
...: | |
...: from tqdm import tqdm | |
...: tqdm.pandas() | |
...: import os |
This file contains 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 pymysql | |
pymysql.install_as_MySQLdb() | |
import logging | |
from configparser import RawConfigParser | |
from sqlalchemy import create_engine | |
from sqlalchemy.engine.url import URL | |
SCHEMA_NANE = "tweets" | |
class mysql_connection(object): |