Kaggle competition: COVID19 Global Forecasting (Week 2)
<SOS> metric: MCRMSLE Kaggle data source: covid19-global-forecasting-(week-2)<load_pretrained>
import pandas as pd
import datetime
import lightgbm as lgb
import numpy as np
from sklearn import preprocessing
tokenizer = AutoTokenizer.from_pretrained(MODEL )<load_from_csv>
train = pd.read_csv(".. /input/covid19-global-forecasting-week-2/train.csv")
 test = pd.read_csv(".. /input/covid19-global-forecasting-week-2/test.csv")
 sub = pd.read_csv(".. /input/covid19-global-forecasting-week-2/submission.csv" )
train1 = pd.read_csv("/kaggle/input/jigsaw-multilingual-toxic-comment-classification/jigsaw-toxic-comment-train.csv")
 train2 = pd.read_csv("/kaggle/input/jigsaw-multilingual-toxic-comment-classification/jigsaw-unintended-bias-train.csv")
 train2.toxic = train2.toxic.round().astype(int)
 valid = pd.read_csv('/kaggle/input/jigsaw-multilingual-toxic-comment-classification/validation.csv')
 test = pd.read_csv('/kaggle/input/jigsaw-multilingual-toxic-comment-classification/test.csv')
 sub = pd.read_csv('/kaggle/input/jigsaw-multilingual-toxic-comment-classification/sample_submission.csv' )<concatenate>
train = train.append(test[test['Date']>'2020-03-31'] )
train = pd.concat([
train1[['comment_text', 'toxic']],
train2[['comment_text', 'toxic']].query('toxic==1'),
train2[['comment_text', 'toxic']].query('toxic==0' ).sample(n=100000, random_state=0)
 ] )<prepare_x_and_y>
train['Date'] = pd.to_datetime(train['Date'], format='%Y-%m-%d' )
%%time
x_train = regular_encode(train.comment_text.values, tokenizer, maxlen=MAX_LEN)
 x_valid = regular_encode(valid.comment_text.values, tokenizer, maxlen=MAX_LEN)
 x_test = regular_encode(test.content.values, tokenizer, maxlen=MAX_LEN)
 y_train = train.toxic.values
y_valid = valid.toxic.values<set_options>
train['day_dist'] = train['Date']-train['Date'].min()
try:
tpu = tf.distribute.cluster_resolver.TPUClusterResolver()
print('Running on TPU ', tpu.master())
 except ValueError:
tpu = None
if tpu:
tf.config.experimental_connect_to_cluster(tpu)
 tf.tpu.experimental.initialize_tpu_system(tpu)
 strategy = tf.distribute.experimental.TPUStrategy(tpu)
 else:
strategy = tf.distribute.get_strategy()
print("REPLICAS: ", strategy.num_replicas_in_sync )<define_variables>
train['day_dist'] = train['day_dist'].dt.days
AUTO = tf.data.experimental.AUTOTUNE
GCS_DS_PATH = KaggleDatasets().get_gcs_path()
EPOCHS = 2
BATCH_SIZE = 16 * strategy.num_replicas_in_sync
MAX_LEN = 192
MODEL = 'jplu/tf-xlm-roberta-large'<define_variables>
cat_cols = train.dtypes[train.dtypes=='object'].keys()
cat_cols
train_dataset =(
 tf.data.Dataset 
.from_tensor_slices(( x_train, y_train)) 
.repeat() 
.shuffle(2048)
.batch(BATCH_SIZE)
.prefetch(AUTO)
)
 valid_dataset =(
 tf.data.Dataset 
.from_tensor_slices(( x_valid, y_valid)) 
.batch(BATCH_SIZE)
.cache() 
.prefetch(AUTO)
)
 test_dataset =(
 tf.data.Dataset 
.from_tensor_slices(x_test)
.batch(BATCH_SIZE)
 )<load_pretrained>
for cat_col in cat_cols:
train[cat_col].fillna('no_value', inplace = True )
%%time
with strategy.scope() :
transformer_layer = TFAutoModel.from_pretrained(MODEL)
 model = build_model(transformer_layer, max_len=MAX_LEN)
 model.summary()<train_model>
train['place'] = train['Province_State']+'_'+train['Country_Region']
n_steps = x_train.shape[0] // BATCH_SIZE
train_history = model.fit(
 train_dataset,
steps_per_epoch=n_steps,
validation_data=valid_dataset,
epochs=EPOCHS
)<train_model>
cat_cols = train.dtypes[train.dtypes=='object'].keys()
cat_cols
n_steps = x_valid.shape[0] // BATCH_SIZE
train_history_2 = model.fit(
 valid_dataset.repeat() ,
steps_per_epoch=n_steps,
epochs=EPOCHS
)<save_to_csv>
for cat_col in ['place']:
le = preprocessing.LabelEncoder()
le.fit(train[cat_col])
 train[cat_col]=le.transform(train[cat_col] )
sub['toxic'] = model.predict(test_dataset, verbose=1)
 sub.to_csv('submission.csv', index=False )<define_variables>
drop_cols = ['Id','ForecastId', 'ConfirmedCases','Date', 'Fatalities',
'day_dist', 'Province_State', 'Country_Region']
DIR = os.getcwd()
DIRimg = ".. /input/all-dogs/all-dogs"
DIRanno = ".. /input/annotation/Annotation"
DIRout = ".. /output_images"<feature_engineering>
val = train[(train['Date']>='2020-03-12')&(train['Id'].isnull() ==False)]
all_fNames = os.listdir(DIRimg)
 x_train = np.zeros(( len(all_fNames),img_size,img_size,3))
j = 0
for i in tqdm(range(len(all_fNames))):
path = os.path.join(DIRimg, all_fNames[i])
 ok, img = loadImage(path)
 if ok:
x_train[j] = img
j += 1
print(j)
 x_train = x_train[:j] / 255 .<categorify>
y_ft = train["Fatalities"]
y_val_ft = val["Fatalities"]
y_cc = train["ConfirmedCases"]
y_val_cc = val["ConfirmedCases"]
input = Input(( 10000,))
x = Dense(2048, activation='elu' )(input)
 x = Reshape(( 8,8,32))(x)
 x = Conv2D(128,(3, 3), activation='elu', padding='same' )(x)
 x = UpSampling2D(( 2, 2))(x)
 x = Conv2D(64,(3, 3), activation='elu', padding='same' )(x)
 x = UpSampling2D(( 2, 2))(x)
 x = Conv2D(32,(3, 3), activation='elu', padding='same' )(x)
 x = UpSampling2D(( 2, 2))(x)
 decoded = Conv2D(3,(3, 3), activation='sigmoid', padding='same' )(x)
 decoder = Model(input, decoded)
 decoder.compile(optimizer=Adam(lr=0.005), loss='binary_crossentropy')
 decoder.summary()<prepare_x_and_y>
def rmsle(y_true, y_pred):
return np.sqrt(np.mean(np.power(np.log1p(y_pred)- np.log1p(y_true), 2)) )
ids = np.random.randint(0,len(x_train),10000)
 train_y = x_train[ids, :,:,:]
train_X = np.eye(10000 )<train_model>
def mape(y_true, y_pred):
return np.mean(np.abs(y_pred -y_true)*100/(y_true+1))
lr = 0.01
batch = 256; ep = 30; it = 10
d_loss = []
for k in range(10):
annealer = LearningRateScheduler(lambda x: lr)
 h = decoder.fit(train_X, train_y, epochs = ep, batch_size = batch,
callbacks=[annealer], verbose=0)
 d_loss.extend(h.history['loss'])
 print('Epoch',(k+1)*ep,'/',ep*it,' loss =',h.history['loss'][-1], '/ lr =',lr)
 if h.history['loss'][-1] / h.history['loss'][0] > 0.99: lr = max(lr/2., 0.0005)
 plt.plot(d_loss)
 plt.show()<drop_column>
dates = dates[dates>'2020-03-31']
del x_train, train_y, train_X<categorify>
params = {
"objective": "regression",
"boosting": 'gbdt',
"num_leaves": 1280,
"learning_rate": 0.05,
"feature_fraction": 0.9,
"reg_lambda": 2,
"metric": "rmse",
'min_data_in_leaf':20
}
def getDog(ids, mix_rate):
imgs = []
for id in ids:
xx = np.zeros(( 10000))
xx[id] = mix_rate
xx[np.random.randint(10000)] = 1.0 - mix_rate
imgs.append(decoder.predict(xx.reshape(( -1,10000)))[0].reshape(img_shape))
return imgs<load_pretrained>
train[train['Date']==date]
shutil.make_archive('images', 'zip', DIRout )<import_modules>
test[test['Country_Region']=='Italy']
import numpy as np
import pandas as pd
import keras
from keras.layers import Input, Dense, Reshape, Flatten, Dropout,Concatenate
from keras.backend import random_normal,ones_like,zeros_like,mean
from keras.backend import get_session
from keras.layers import BatchNormalization, Activation, ZeroPadding2D
from keras.layers.advanced_activations import LeakyReLU
from keras.layers.convolutional import UpSampling2D, Conv2D
from keras.models import Sequential, Model
from keras.optimizers import Adam
from keras.layers import concatenate
from keras.initializers import TruncatedNormal
from keras.callbacks import LearningRateScheduler, EarlyStopping, History
from PIL import Image
import warnings
import os
import time
from glob import glob
import datetime
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np, pandas as pd, os
import xml.etree.ElementTree as ET
import matplotlib.pyplot as plt, zipfile
from PIL import Image
from glob import glob<define_variables>
test[(test['Country_Region']=='China')&(test['Province_State']=='Zhejiang')]
ComputeLB = False
DogsOnly = False
ROOT = '.. /input/generative-dog-images/'
if not ComputeLB: ROOT = '.. /input/'
IMAGES = os.listdir(ROOT + 'all-dogs/all-dogs/')
 breeds = os.listdir(ROOT + 'annotation/Annotation/')
 idxIn = 0; namesIn = []
imagesIn = np.zeros(( 25000,64,64,3))
if DogsOnly:
for breed in breeds:
for dog in os.listdir(ROOT+'annotation/Annotation/'+breed):
try: img = Image.open(ROOT+'all-dogs/all-dogs/'+dog+'.jpg')
 except: continue
tree = ET.parse(ROOT+'annotation/Annotation/'+breed+'/'+dog)
 root = tree.getroot()
objects = root.findall('object')
 for o in objects:
bndbox = o.find('bndbox')
 xmin = int(bndbox.find('xmin' ).text)
 ymin = int(bndbox.find('ymin' ).text)
 xmax = int(bndbox.find('xmax' ).text)
 ymax = int(bndbox.find('ymax' ).text)
 w = np.min(( xmax - xmin, ymax - ymin))
img2 = img.crop(( xmin, ymin, xmin+w, ymin+w))
img2 = img2.resize(( 64,64), Image.ANTIALIAS)
 imagesIn[idxIn,:,:,:] = np.asarray(img2)
 namesIn.append(breed)
 idxIn += 1
idx = np.arange(idxIn)
 np.random.shuffle(idx)
 imagesIn = imagesIn[idx,:,:,:]
namesIn = np.array(namesIn)[idx]
else:
IMAGES = np.sort(IMAGES)
 np.random.seed(810)
 x = np.random.choice(np.arange(20579),10000)
 np.random.seed(None)
 for k in range(len(x)) :
img = Image.open(ROOT + 'all-dogs/all-dogs/' + IMAGES[x[k]])
 w = img.size[0]; h = img.size[1];
if(k%2==0)|(k%3==0):
w2 = 100; h2 = int(h/(w/100))
a = 18; b = 0
else:
a=0; b=0
if w<h:
w2 = 64; h2 = int(( 64/w)*h)
 b =(h2-64)//2
else:
h2 = 64; w2 = int(( 64/h)*w)
 a =(w2-64)//2
img = img.resize(( w2,h2), Image.ANTIALIAS)
 img = img.crop(( 0+a, 0+b, 64+a, 64+b))
imagesIn[idxIn,:,:,:] = np.asarray(img)
 namesIn.append(IMAGES[x[k]])
 idxIn += 1
x = np.random.randint(0,idxIn,25)
 for k in range(5):
plt.figure(figsize=(15,3))
for j in range(5):
plt.subplot(1,5,j+1)
 img = Image.fromarray(imagesIn[x[k*5+j],:,:,:].astype('uint8'))
plt.axis('off')
 if not DogsOnly: plt.title(namesIn[x[k*5+j]],fontsize=11)
 else: plt.title(namesIn[x[k*5+j]].split('-')[1],fontsize=11)
 plt.imshow(img)
 plt.show()<define_variables>
test[test['Country_Region']=='Italy']
IMG_SIZE = Input(( 12288,))
IMG_SIZE_2 = Input(( 10000,))
NOISE_SIZE = 10000
BATCH_SIZE = 64<choose_model_class>
train_sub = pd.read_csv(".. /input/covid19-global-forecasting-week-2/train.csv" )
def discriminatorFunction() :
input_layer = Dense(12288, activation='sigmoid' )(IMG_SIZE_2)
 input_layer = Reshape(( 2,12288,1))(concatenate([IMG_SIZE,input_layer]))
discriminator = Conv2D(filters = 1, kernel_size=[2,1],use_bias=False, name = 'layer_1' )(input_layer)
 out = Flatten()(discriminator)
 return out<choose_model_class>
test = pd.merge(test,train_sub[['Province_State','Country_Region',
'Date','ConfirmedCases',
'Fatalities']],
on=['Province_State','Country_Region',
'Date'], how='left' )
print("Discriminator")
 model = discriminatorFunction()
model_discriminator = Model([IMG_SIZE,IMG_SIZE_2], model)
 model_discriminator.get_layer('layer_1' ).trainable = False
model_discriminator.get_layer('layer_1' ).set_weights([np.array([[[[-1.0 ]]],[[[1.0]]]])])
 model_discriminator.summary()
model_discriminator.compile(optimizer='adam', loss='binary_crossentropy' )<choose_model_class>
test.loc[test['ConfirmedCases_x'].isnull() ==True]
def GeneratorFunction(noise_shape=(NOISE_SIZE,)) :
input_layer = Input(noise_shape)
 generated = Dense(12288, activation='linear' )(input_layer)
 model = Model(inputs=input_layer,outputs = [generated,Reshape(( 10000,))(input_layer)])
 model.summary()
return model<choose_model_class>
test.loc[test['ConfirmedCases_x'].isnull() ==True, 'ConfirmedCases_x'] =test.loc[test['ConfirmedCases_x'].isnull() ==True, 'ConfirmedCases_y']
print("Generator")
 model_generator = GeneratorFunction(noise_shape=(NOISE_SIZE,))<train_model>
test.loc[test['Fatalities_x'].isnull() ==True, 'Fatalities_x'] = test.loc[test['Fatalities_x'].isnull() ==True, 'Fatalities_y']
train_y =(imagesIn[:10000,:,:,:]/255.).reshape(( -1,12288))
train_X = np.zeros(( 10000,10000))
for i in range(10000): train_X[i,i] = 1
zeros = np.zeros(( 10000,12288))
lr = 0.5
for k in range(5):
LR_Scheduler = LearningRateScheduler(lambda x: lr)
 h = model_discriminator.fit([zeros,train_X], train_y, epochs = 100,batch_size = BATCH_SIZE, callbacks=[LR_Scheduler], verbose=0)
 print('Epoch',(k+1)*10,'/50 - loss =',h.history['loss'][-1])
 if h.history['loss'][-1]<0.533: lr = 0.1<drop_column>
last_amount = test.loc[(test['Country_Region']=='Italy')&(test['Date']=='2020-03-31'),'ConfirmedCases_x']
del train_X, train_y, imagesIn<choose_model_class>
last_fat = test.loc[(test['Country_Region']=='Italy')&(test['Date']=='2020-03-31'),'Fatalities_x']
model_discriminator.trainable = False
z = Input(shape=(NOISE_SIZE,))
img = model_generator(z)
 real = model_discriminator(img)
 gan = Model(z, real)
 gan.get_layer('model_1' ).get_layer('layer_1' ).set_weights([np.array([[[[-1 ]]],[[[255.]]]])])
 gan.compile(optimizer=Adam(5), loss='mean_squared_error')
 print("Model created based on Discriminator and Generator")
 gan.summary()<train_model>
i = 0
k = 30
train = np.zeros(( 10000,10000))
for i in range(10000): train[i,i] = 1
zeros = np.zeros(( 10000,12288))
Steps_per_epoch = 50
print("Training begins...Total steps per epoch: {}".format(Steps_per_epoch)) 
<train_model>
test.loc[(test['Country_Region']=='Italy')]
warnings.filterwarnings("ignore")
 lr = 5.
 for step in range(Steps_per_epoch):
LR_Scheduler = LearningRateScheduler(lambda x: lr)
 h = gan.fit(train, zeros, epochs = 1, batch_size=256, callbacks=[LR_Scheduler], verbose=0)
 if(step<10)|(step%5==4):
print("Step: {}/{} [G loss: {:.4f}]".format(
(step+1)*10, Steps_per_epoch*10, h.history['loss'][-1]))
if h.history['loss'][-1] < 25: lr = 1.
 if h.history['loss'][-1] < 1.5: lr = 0.01
if step<10:
plt.figure(figsize=(15,3))
for j in range(5):
zz = np.zeros(( 10000))
zz[np.random.randint(10000)] = 1
plt.subplot(1,5,j+1)
 img = model_generator.predict(zz.reshape(( -1,10000)))[0].reshape(( -1,64,64,3))
img = Image.fromarray(( img ).astype('uint8' ).reshape(( 64,64,3)))
 plt.axis('off')
 plt.imshow(img)
 plt.show()<predict_on_test>
for date in dates:
k = k-1
i = i+1
test.loc[(test['Country_Region']=='Italy')&(test['Date']==date),
'ConfirmedCases_x']=last_amount.values[0] + i*(5000-(100*i))
test.loc[(test['Country_Region']=='Italy')&(test['Date']==date),
'Fatalities_x'] = last_fat.values[0]+i*(800-(10*i))
class DogGenerator:
index = 0
def getDog(self,seed):
xx = np.zeros(( 10000))
xx[self.index] = 0.999
xx[np.random.randint(10000)] = 0.001
img = model_generator.predict(xx.reshape(( -1,10000)))[0].reshape(( 64,64,3))
self.index =(self.index+1)%10000
return Image.fromarray(img.astype('uint8'))<define_variables>
test.loc[(test['Country_Region']=='Italy')]
ComputeLB = False
DogsOnly = False
ROOT = '.. /input/generative-dog-images/'
if not ComputeLB: ROOT = '.. /input/'
IMAGES = os.listdir(ROOT + 'all-dogs/all-dogs/')
 breeds = os.listdir(ROOT + 'annotation/Annotation/')
 idxIn = 0; namesIn = []
imagesIn = np.zeros(( 25000,64,64,3))
if DogsOnly:
for breed in breeds:
for dog in os.listdir(ROOT+'annotation/Annotation/'+breed):
try: img = Image.open(ROOT+'all-dogs/all-dogs/'+dog+'.jpg')
 except: continue
tree = ET.parse(ROOT+'annotation/Annotation/'+breed+'/'+dog)
 root = tree.getroot()
objects = root.findall('object')
 for o in objects:
bndbox = o.find('bndbox')
 xmin = int(bndbox.find('xmin' ).text)
 ymin = int(bndbox.find('ymin' ).text)
 xmax = int(bndbox.find('xmax' ).text)
 ymax = int(bndbox.find('ymax' ).text)
 w = np.min(( xmax - xmin, ymax - ymin))
img2 = img.crop(( xmin, ymin, xmin+w, ymin+w))
img2 = img2.resize(( 64,64), Image.ANTIALIAS)
 imagesIn[idxIn,:,:,:] = np.asarray(img2)
 namesIn.append(breed)
 idxIn += 1
else:
x = np.random.choice(np.arange(20000),10000)
 for k in range(len(x)) :
img = Image.open(ROOT + 'all-dogs/all-dogs/' + IMAGES[x[k]])
 w = img.size[0]; h = img.size[1];
if(k%2==0)|(k%3==0):
w2 = 100; h2 = int(h/(w/100))
a = 18; b = 0
else:
a=0; b=0
if w<h:
w2 = 64; h2 = int(( 64/w)*h)
 b =(h2-64)//2
else:
h2 = 64; w2 = int(( 64/h)*w)
 a =(w2-64)//2
img = img.resize(( w2,h2), Image.ANTIALIAS)
 img = img.crop(( 0+a, 0+b, 64+a, 64+b))
imagesIn[idxIn,:,:,:] = np.asarray(img)
 namesIn.append(IMAGES[x[k]])
 idxIn += 1
x = np.random.randint(0,idxIn,25)
 for k in range(5):
plt.figure(figsize=(15,3))
for j in range(5):
plt.subplot(1,5,j+1)
 img = Image.fromarray(imagesIn[x[k*5+j],:,:,:].astype('uint8'))
plt.axis('off')
 if not DogsOnly: plt.title(namesIn[x[k*5+j]],fontsize=11)
 else: plt.title(namesIn[x[k*5+j]].split('-')[1],fontsize=11)
 plt.imshow(img)
 plt.show()<import_modules>
last_amount = test.loc[(test['Country_Region']=='China')&(test['Province_State']!='Hubei')&(test['Date']=='2020-03-31'),'ConfirmedCases_x']
last_fat = test.loc[(test['Country_Region']=='China')&(test['Province_State']!='Hubei')&(test['Date']=='2020-03-31'),'Fatalities_x']
from keras.models import Model
from keras.layers import Input, Dense, Conv2D, MaxPooling2D, UpSampling2D, Reshape, BatchNormalization
from keras.preprocessing.image import ImageDataGenerator
from keras.callbacks import LearningRateScheduler
from keras.optimizers import SGD, Adam<categorify>
i = 0
k = 30
for date in dates:
k = k-1
i = i+1
test.loc[(test['Country_Region']=='China')&(test['Province_State']!='Hubei')&(test['Date']==date),
'Fatalities_x']= last_fat.values
test.loc[(test['Country_Region']=='China')&(test['Province_State']!='Hubei')&(test['Date']==date),
'ConfirmedCases_x']= last_amount.values + i
direct_input = Input(( 10000,))
x = Dense(2048, activation='elu' )(direct_input)
 x = Reshape(( 8,8,32))(x)
 x = Conv2D(128,(3, 3), activation='elu', padding='same' )(x)
 x = UpSampling2D(( 2, 2))(x)
 x = Conv2D(64,(3, 3), activation='elu', padding='same' )(x)
 x = UpSampling2D(( 2, 2))(x)
 x = Conv2D(32,(3, 3), activation='elu', padding='same' )(x)
 x = UpSampling2D(( 2, 2))(x)
 decoded = Conv2D(3,(3, 3), activation='sigmoid', padding='same' )(x)
 decoder = Model(direct_input, decoded)
 decoder.compile(optimizer=Adam(lr=0.005), loss='binary_crossentropy')
 decoder.summary()<prepare_x_and_y>
last_amount = test.loc[(test['Country_Region']=='China')&(test['Province_State']=='Hubei')&(test['Date']=='2020-03-31'),'ConfirmedCases_x']
last_fat = test.loc[(test['Country_Region']=='China')&(test['Province_State']=='Hubei')&(test['Date']=='2020-03-31'),'Fatalities_x']
idx = np.random.randint(0,idxIn,10000)
 train_y = imagesIn[idx,:,:,:]/255.
 train_X = np.zeros(( 10000,10000))
for i in range(10000): train_X[i,i] = 1<categorify>
k=30
i=0
for date in dates:
k = k-1
i = i+1
test.loc[(test['Country_Region']=='China')&(test['Province_State']=='Hubei')&(test['Date']==date),'ConfirmedCases_x']= last_amount.values[0]
test.loc[(test['Country_Region']=='China')&(test['Province_State']=='Hubei')&(test['Date']==date),'Fatalities_x']= last_fat.values[0] + i
lr = 0.005
for k in range(50):
annealer = LearningRateScheduler(lambda x: lr)
 h = decoder.fit(train_X, train_y, epochs = 10, batch_size=256, callbacks=[annealer], verbose=0)
 if k%5==4: print('Epoch',(k+1)*10,'/500 - loss =',h.history['loss'][-1])
 if h.history['loss'][-1]<0.54: lr = 0.001<drop_column>
sub = test[['ForecastId','ConfirmedCases_x','Fatalities_x']]
del train_X, train_y, imagesIn<categorify>
sub.columns=['ForecastId','ConfirmedCases','Fatalities']
print('Generate Random Dogs')
 for k in range(5):
plt.figure(figsize=(15,3))
for j in range(5):
xx = np.zeros(( 10000))
xx[np.random.randint(10000)] = 1
xx[np.random.randint(10000)] = 0.75
xx = xx/(np.sqrt(xx.dot(xx.T)))
 plt.subplot(1,5,j+1)
 img = decoder.predict(xx.reshape(( -1,10000)))
 img = Image.fromarray(( 255*img ).astype('uint8' ).reshape(( 64,64,3)))
 plt.axis('off')
 plt.imshow(img)
 plt.show()<categorify>
sub.loc[sub['ConfirmedCases']<0,'ConfirmedCases']=0
print('Recall from Memory Dogs')
 for k in range(5):
plt.figure(figsize=(15,3))
for j in range(5):
xx = np.zeros(( 10000))
xx[np.random.randint(10000)] = 1
plt.subplot(1,5,j+1)
 img = decoder.predict(xx.reshape(( -1,10000)))
 img = Image.fromarray(( 255*img ).astype('uint8' ).reshape(( 64,64,3)))
 plt.axis('off')
 plt.imshow(img)
 plt.show()<categorify>
sub.loc[sub['Fatalities']<0, 'Fatalities']=0
<choose_model_class><EOS> 
sub.to_csv('submission.csv',index=False )