Skip to content

Instantly share code, notes, and snippets.

View Vishnunkumar's full-sized avatar
😉
Exploring Dev

Vishnu Nandakumar Vishnunkumar

😉
Exploring Dev
View GitHub Profile
c_model = tf.keras.models.Sequential()
c_model.add(tf.keras.layers.Input(shape=(224, 224, 3)))
c_model.add(tf.keras.layers.Conv2D(filters=256, kernel_size=(3, 3),
activation='relu', padding='same'))
c_model.add(tf.keras.layers.MaxPooling2D(pool_size=(2, 2)))
c_model.add(tf.keras.layers.Conv2D(filters=128, kernel_size=(3, 3),
activation='relu', padding='same'))
c_model.add(tf.keras.layers.MaxPooling2D(pool_size=(2, 2)))
c_model.add(tf.keras.layers.Conv2D(filters=64, kernel_size=(3, 3),
activation='relu', padding='same'))
scaler = preprocessing.StandardScaler()
tr_path = 'input/rdocuments/rdocuments/'
tr_csv = 'input/rdocuments/r-images.csv'
train_label_df = pd.read_csv(tr_csv)
train_label_df['angle'] = train_label_df['angle'].apply(lambda x: -1*(x))
train_label_df['angle_scaled'] = scaler.fit_transform(train_label_df['angle'].values.reshape(len(train_label_df), 1))
(img_width, img_height) = (224, 224)
BATCH_SIZE = 64
class Augmentation:
def __init__(self, path):
self.path = path
def rotate_images(self, op, iterations):
self.op = op
self.iterations = iterations
os.mkdir(self.op)
print(f"created {self.op} directory")
class RandomNoiser():
def __init__(self, n_words):
self.n_words = n_words
def noiser(self, text):
self.text = text
json_dict = {}
from transformers import AutoTokenizer, T5ForConditionalGeneration, pipeline
tokenizer = AutoTokenizer.from_pretrained("vishnun/t5spellcorrector")
model = T5ForConditionalGeneration.from_pretrained("vishnun/t5spellcorrector")
zc = pipeline('zero-shot-classification', model='bert-base-uncased')
class Grammarly():
def __init__(self, text):
self.text = text
import eng_spacysentiment
nlp = eng_spacysentiment.load()
text = "Welcome to Arsenal's official YouTube channel Watch as we take you closer and show you the personality of the club."
doc = nlp(text)
doc.cats
# {'positive': 0.993678629398346, 'negative': 0.006321393419057131}
# data processing
train_texts = df['text'].values
train_labels = [{'cats': {'positive': label == 'positive',
'negative': label == 'negative'}}
for label in df['sentiment']]
# training the model
nlp = spacy.blank("en")
config = Config().from_str(single_label_bow_config)
[
{
"key": "TERMINAL #"
},
{
"value": "65425899"
},
{
"key": "SEQUNCE #"
},
# normalization
df = pd.read_csv('input/fifa-filtered-20/fif_20.csv')
df_np = preprocessing.normalize(df.iloc[:,:-1])
# creating searcher
k = int(np.sqrt(df_np.shape[0]))
searcher = scann.scann_ops_pybind.builder(df_np, 10, "dot_product").tree(
num_leaves=k, num_leaves_to_search=int(k/20), training_sample_size=2500).score_brute_force(2).reorder(7).build()
# querying the searcher
We can make this file beautiful and searchable if this error is corrected: It looks like row 2 should actually have 80 columns, instead of 14 in line 1.
name,age,overall,potential,international_reputation,skill_moves,weak_foot,nation_jersey_number,pace,shooting,passing,dribbling,defending,physic,gk_diving,gk_handling,gk_kicking,gk_reflexes,gk_speed,gk_positioning,attacking_crossing,attacking_finishing,attacking_heading_accuracy,attacking_short_passing,attacking_volleys,skill_dribbling,skill_curve,skill_fk_accuracy,skill_long_passing,skill_ball_control,movement_acceleration,movement_sprint_speed,movement_agility,movement_reactions,movement_balance,power_shot_power,power_jumping,power_stamina,power_strength,power_long_shots,mentality_aggression,mentality_interceptions,mentality_positioning,mentality_vision,mentality_penalties,mentality_composure,defending_marking,defending_standing_tackle,defending_sliding_tackle,goalkeeping_diving,goalkeeping_handling,goalkeeping_kicking,goalkeeping_positioning,goalkeeping_reflexes,ls,st,rs,lw,lf,cf,rf,rw,lam,cam,ram,lm,lcm,cm,rcm,rm,lwb,ldm,cdm,rdm,rwb,lb,lcb,cb,rcb,rb
lionel messi,32,94,94,5,4,4,0.0,87.0,92.0,92.0,96.0,39.0,