Kaggle competition: Prostate cANcer graDe Assessment (PANDA) Challenge
submission = pd.read_csv('.. /input/sample_submission.csv')
 print(len(submission))
submission.head()<predict_on_test>
from __future__ import print_function, absolute_import
import os
import sys
import time
import datetime
import argparse
import os.path as osp
import numpy as np
import random
from PIL import Image
import tqdm
import cv2
import csv
import math
import torchvision as tv
import torchvision
import torch.nn.functional as F
import torch.optim as optim
import torch
import torch.nn as nn
import torch.backends.cudnn as cudnn
from sklearn.metrics import f1_score
from torch.utils.data import DataLoader
from torch.autograd import Variable
from torch.optim import lr_scheduler
from tqdm import tqdm
from torch.utils.data import Dataset
import torchvision.transforms as transforms
from tensorboardX import SummaryWriter
import skimage.io
preds_test = []
for i in range(N_SPLITS):
model.load_weights('weights_{}.h5'.format(i))
pred = model.predict([X_test_input, features_test], batch_size=300, verbose=1)
 pred_3 = []
for pred_scalar in pred:
for i in range(3):
pred_3.append(pred_scalar)
 preds_test.append(pred_3)
<data_type_conversions>
name_file='.. /input/prostate-cancer-grade-assessment/test.csv'
data_dir = '.. /input/prostate-cancer-grade-assessment'
image_folder = os.path.join(data_dir, 'test_images')
 is_test = os.path.exists(image_folder)
 image_folder = image_folder if is_test else os.path.join(data_dir, 'train_images')
 csv_file=csv.reader(open(name_file,'r'))
content=[]
for line in csv_file:
print(line[0])
 content.append(line[0]+'.tiff')
 content=content[1:]
if not is_test:
content.append('002a4db09dad406c85505a00fb6f6144.tiff')
 content.append('007433133235efc27a39f11df6940829.tiff')
 content.append('0018ae58b01bdadc8e347995b69f99aa.tiff')
 content.append('0076bcb66e46fb485f5ba432b9a1fe8a.tiff')
 content.append('003d4dd6bd61221ebc0bfb9350db333f.tiff')
 content=content[3:]
print(content )
preds_test =(np.squeeze(np.mean(preds_test, axis=0)) > best_threshold ).astype(np.int)
 preds_test.shape<save_to_csv>
def gem(x, p=3, eps=1e-6):
return F.avg_pool2d(x.clamp(min=eps ).pow(p),(x.size(-2), x.size(-1)) ).pow(1./p)
 class GeM(nn.Module):
def __init__(self, p=3, eps=1e-6):
super(GeM,self ).__init__()
self.p = Parameter(torch.ones(1)*p)
 self.eps = eps
def forward(self, x):
return gem(x, p=self.p, eps=self.eps)
 def __repr__(self):
return self.__class__.__name__ + '(' + 'p=' + '{:.4f}'.format(self.p.data.tolist() [0])+ ', ' + 'eps=' + str(self.eps)+ ')'
submission['target'] = preds_test
submission.to_csv('submission.csv', index=False)
 submission.head()<load_from_csv>
def get_tiles_combine(img,mode=0):
images = np.ones(( 1536, 1536, 3)) *255
h, w, c = img.shape
result_all=[]
pad_h =(256 - h % 256)% 256 +(( 256 * mode)// 2)
 pad_w =(256 - w % 256)% 256 +(( 256 * mode)// 2)
 img2 = np.pad(img,[[pad_h // 2, pad_h - pad_h // 2], [pad_w // 2,pad_w - pad_w//2], [0,0]], 'constant',constant_values=255)
 windows=[256,256,256,256,192,192,128]
x_start=0
for i in range(len(windows)) :
result = []
window_size=windows[i]
for x in range(( h+pad_h)//window_size):
for y in range(( w+pad_w)//window_size):
tile=img2[x*window_size:(x+1)*window_size,y*window_size:(y+1)*window_size]
result.append([x,y,tile.sum() ])
 result.sort(key=lambda ele:ele[2])
 result=result[:1536//window_size]
for y in range(min(1536//window_size,len(result))):
xx=result[y][0]
yy=result[y][1]
result_all.append([xx,yy])
 images[x_start:x_start+window_size,y*window_size:(y+1)*window_size]=\
img2[xx*window_size:(xx+1)*window_size,yy*window_size:(yy+1)*window_size].copy()
img2[xx*window_size:(xx+1)*window_size,yy*window_size:(yy+1)*window_size]=255
x_start=x_start+windows[i]
return images
class panda_dataset_combine(Dataset):

 def __init__(self, txt_path,transform=None):
imgs = []
for img in txt_path:
imgs.append(img)
 self.imgs = imgs
self.transform = transform
def __getitem__(self, index):
fn = self.imgs[index]
tif_name=fn
img_name=tif_name[:-5]
print(image_folder+'/'+tif_name)
 img=skimage.io.MultiImage(image_folder+'/'+tif_name)[1]
images=get_tiles_combine(img)
 images2=get_tiles_combine(img,mode=2)
 images=images.astype(np.float32)
 images=cv2.cvtColor(images,cv2.COLOR_BGR2RGB)
 images2=images2.astype(np.float32)
 images2=cv2.cvtColor(images2,cv2.COLOR_BGR2RGB)
 images3=cv2.flip(images,0)
 images4=cv2.flip(images2,0)
 images5=cv2.flip(images,1)
 images6=cv2.flip(images2,1)
 images = Image.fromarray(np.uint8(images))
images2 = Image.fromarray(np.uint8(images2))
images3 = Image.fromarray(np.uint8(images3))
images4 = Image.fromarray(np.uint8(images4))
images5 = Image.fromarray(np.uint8(images5))
images6 = Image.fromarray(np.uint8(images6))
if self.transform is not None:
img = self.transform(images)
 img2= self.transform(images2)
 img3= self.transform(images3)
 img4= self.transform(images4)
 img5= self.transform(images5)
 img6= self.transform(images6)
 return img_name,img,img2,img3,img4,img5,img6
def __len__(self):
return len(self.imgs )
v_raw_train = pq.read_pandas('.. /input/train.parquet' ).to_pandas().values
meta_train = np.loadtxt('.. /input/metadata_train.csv', skiprows=1, delimiter=',')
 y_train = meta_train[:, 3].astype(bool)
 print(v_raw_train.shape )<define_search_space>
tile_size = 256
image_size = 256
n_tiles = 36
batch_size = 8
num_workers = 4
def get_tiles(img, mode=0):
result = []
h, w, c = img.shape
pad_h =(tile_size - h % tile_size)% tile_size +(( tile_size * mode)// 2)
 pad_w =(tile_size - w % tile_size)% tile_size +(( tile_size * mode)// 2)
 img2 = np.pad(img,[[pad_h // 2, pad_h - pad_h // 2], [pad_w // 2,pad_w - pad_w//2], [0,0]], 'constant',constant_values=255)
 img3 = img2.reshape(
 img2.shape[0] // tile_size,
tile_size,
img2.shape[1] // tile_size,
tile_size,
3 
)
 img3 = img3.transpose(0,2,1,3,4 ).reshape(-1, tile_size, tile_size,3)
 n_tiles_with_info =(img3.reshape(img3.shape[0],-1 ).sum(1)< tile_size ** 2 * 3 * 255 ).sum()
if len(img3)< n_tiles:
img3 = np.pad(img3,[[0,n_tiles-len(img3)],[0,0],[0,0],[0,0]], constant_values=255)
 idxs = np.argsort(img3.reshape(img3.shape[0],-1 ).sum(-1)) [:n_tiles]
img3 = img3[idxs]
for i in range(len(img3)) :
result.append({'img':img3[i], 'idx':i})
 return result, n_tiles_with_info >= n_tiles
class panda_dataset(Dataset):

 def __init__(self, txt_path,transform=None):
imgs = []
for img in txt_path:
imgs.append(img)
 self.imgs = imgs
self.transform = transform
def __getitem__(self, index):
fn = self.imgs[index]
tif_name=fn
img_name=tif_name[:-5]
print(image_folder+'/'+tif_name)
 img=skimage.io.MultiImage(image_folder+'/'+tif_name)[1]
tiles,flag=get_tiles(img)
 tiles2,flag2=get_tiles(img,mode=2)
 idxes = list(range(n_tiles))
n_row_tiles = int(np.sqrt(n_tiles))
images = np.zeros(( image_size * n_row_tiles, image_size * n_row_tiles, 3))
for h in range(n_row_tiles):
for w in range(n_row_tiles):
i = h * n_row_tiles + w
if len(tiles)> idxes[i]:
this_img = tiles[idxes[i]]['img']
else:
this_img = np.ones(( image_size, image_size, 3)).astype(np.uint8)* 255
this_img = 255 - this_img
h1 = h * image_size
w1 = w * image_size
images[h1:h1+image_size, w1:w1+image_size] = this_img
images=255-images
images=images.astype(np.float32)
 images=cv2.cvtColor(images,cv2.COLOR_BGR2RGB)
 print(images.shape)
 images=images/255
images2 = np.zeros(( image_size * n_row_tiles, image_size * n_row_tiles, 3))
for h in range(n_row_tiles):
for w in range(n_row_tiles):
i = h * n_row_tiles + w
if len(tiles2)> idxes[i]:
this_img = tiles2[idxes[i]]['img']
else:
this_img = np.ones(( image_size, image_size, 3)).astype(np.uint8)* 255
this_img = 255 - this_img
h1 = h * image_size
w1 = w * image_size
images2[h1:h1+image_size, w1:w1+image_size] = this_img
images2=255-images2
images2=images2.astype(np.float32)
 images2=cv2.cvtColor(images2,cv2.COLOR_BGR2RGB)
 print(images2.shape)
 images2=images2/255
images3=cv2.flip(images,0)
 images4=cv2.flip(images2,0)
 images5=cv2.flip(images,1)
 images6=cv2.flip(images2,1)
 images_com=get_tiles_combine(img)
 images_com2=get_tiles_combine(img,mode=2)
 images_com=images_com.astype(np.float32)
 images_com=cv2.cvtColor(images_com,cv2.COLOR_BGR2RGB)
 images_com2=images_com2.astype(np.float32)
 images_com2=cv2.cvtColor(images_com2,cv2.COLOR_BGR2RGB)
 images_com3=cv2.flip(images_com,0)
 images_com4=cv2.flip(images_com2,0)
 images_com5=cv2.flip(images_com,1)
 images_com6=cv2.flip(images_com2,1)
 images_com = Image.fromarray(np.uint8(images_com))
images_com2 = Image.fromarray(np.uint8(images_com2))
images_com3 = Image.fromarray(np.uint8(images_com3))
images_com4 = Image.fromarray(np.uint8(images_com4))
images_com5 = Image.fromarray(np.uint8(images_com5))
images_com6 = Image.fromarray(np.uint8(images_com6))
if self.transform is not None:
img = self.transform(images)
 img2= self.transform(images2)
 img3= self.transform(images3)
 img4= self.transform(images4)
 img5= self.transform(images5)
 img6= self.transform(images6)
 img_com=self.transform(images_com)
 img_com2= self.transform(images_com2)
 img_com3= self.transform(images_com3)
 img_com4= self.transform(images_com4)
 img_com5= self.transform(images_com5)
 img_com6= self.transform(images_com6)
 imgs=[img,img2,img3,img4,img5,img6]
imgs_com=[img_com,img_com2,img_com3,img_com4,img_com5,img_com6]
return img_name,imgs,imgs_com
def __len__(self):
return len(self.imgs )
def compute_spectra(v_raw, *, m = 1000):

 percentile =(100, 99, 95, 0, 1, 5)
 n = v_raw.shape[1]
length = v_raw.shape[0] // m
n_spectra = len(percentile)
 mean_signal = np.zeros(( n, length), dtype='float32')
 percentile_spectra = np.zeros(( n, length, n_spectra), dtype='float32')
 print('computing spectra...', flush=True)
 for i in tqdm(range(n)) :
v = v_raw[:, i].astype('float32' ).reshape(-1, m)/ 128.0
mean = np.mean(v, axis=1)
 s = np.abs(np.percentile(v, percentile, axis=1)- mean)
 h = np.percentile(s, 5.0)
 s = np.maximum(0.0, s - h)
 mean_signal[i, :] = mean
percentile_spectra[i, :, :] = s.T
d = {}
d['mean'] = mean_signal
d['percentile'] = percentile_spectra
return d
spec_train = compute_spectra(v_raw_train)
 print('done.' )<init_hyperparams>
def load_para_dict(model1):
state_dict_1=torch.load(model1)
 new_state_dict = OrderedDict()
for k, v in state_dict_1.items() :
if 'module' in k:
name = k[7:]
else:
name=k
new_state_dict[name] = v
return new_state_dict
def get_preds(arr):
mask = arr == 0
return np.clip(np.where(mask.any(1), mask.argmax(1), 6)- 1, 0, 5)
 init_coef = [0.5, 1.5, 2.5, 3.5, 4.5]
def get_preds_reg(arr,coef=init_coef):
X_p = np.copy(arr.detach().cpu())
 for i, pred in enumerate(X_p):
if pred < coef[0]:
X_p[i] = 0
elif pred >= coef[0] and pred < coef[1]:
X_p[i] = 1
elif pred >= coef[1] and pred < coef[2]:
X_p[i] = 2
elif pred >= coef[2] and pred < coef[3]:
X_p[i] = 3
elif pred >= coef[3] and pred < coef[4]:
X_p[i] = 4
else:
X_p[i] = 5
return X_p
def max_windowed(spec, *, width=150, stride=10):

 n = spec.shape[0]
length = spec.shape[1]
nspec = spec.shape[2]
n_triplet = n // 3
max_spec3 = np.empty(( n_triplet, length, 3))
for i_triplet in range(n_triplet):
max_spec3[i_triplet, :, 0] = spec[3*i_triplet, :, 0]
max_spec3[i_triplet, :, 1] = spec[3*i_triplet + 1, :, 0]
max_spec3[i_triplet, :, 2] = spec[3*i_triplet + 2, :, 0]
x = tf.placeholder(tf.float32, [None, length, 3])
 K = np.ones(( width, 3, 1), dtype='float32')/ width
W_conv1 = tf.constant(K)
 h_conv1 = tf.nn.conv1d(x, W_conv1, stride=stride, padding='VALID')
 with tf.Session() as sess:
w = sess.run(h_conv1, feed_dict={x:max_spec3})
 imax = np.argmax(w[:, :, 0], axis=1)
 d = {}
d['w'] = w
d['ibegin'] = imax*stride
return d
peaks = max_windowed(spec_train['percentile'] )<normalization>
def compute_features(v_raw, spec=None):

 if spec is None:
spec = compute_spectra(v_raw)
 v_spec = spec['percentile']
shape = v_spec.shape
n = shape[0]
length = shape[1]
nspec = shape[2]
n_triplet = n // 3
spec3 = np.empty(( n_triplet, length, nspec, 3))
for i_triplet in range(n_triplet):
spec3[i_triplet, :, :, 0] = v_spec[3*i_triplet, :, :]
spec3[i_triplet, :, :, 1] = v_spec[3*i_triplet + 1, :, :]
spec3[i_triplet, :, :, 2] = v_spec[3*i_triplet + 2, :, :]
width = 150
peaks = max_windowed(v_spec, width=width)
 n_feature4 = 3
X = np.empty(( n_triplet, n_feature4*nspec*3 + 3))
X4 = np.empty(( n_triplet, n_feature4, nspec, 3))
for i_triplet in range(n_triplet):
X4[i_triplet, 0, :, :] = np.max(spec3[i_triplet, :, :, :], axis=0)
 ibegin = peaks['ibegin'][i_triplet]
iend = ibegin + width
imid = ibegin + width // 2
X4[i_triplet, 1, :, :] = np.mean(spec3[i_triplet, ibegin:iend, :, :], axis=0)
 X4[i_triplet, 2, :, :] = np.max(spec3[i_triplet, ibegin:iend, :, :], axis=0)
 X[i_triplet, 0] = spec['mean'][3*i_triplet, imid]
X[i_triplet, 1] = spec['mean'][3*i_triplet + 1, imid]
X[i_triplet, 2] = spec['mean'][3*i_triplet + 2, imid]
shape = X4.shape
X[:, 3:] = X4.reshape(shape[0], shape[1]*shape[2]*shape[3])
 return X
X_all3 = compute_features(v_raw_train, spec_train)
 y_all3 = np.sum(y_train.reshape(-1, 3), axis=1)>= 2
print('Three phases are combined into one training data; the shapes are, therefore,')
 print(X_all3.shape, y_all3.shape )<train_model>
def gem(x, p=3, eps=1e-6):
return F.avg_pool2d(x.clamp(min=eps ).pow(p),(x.size(-2), x.size(-1)) ).pow(1./p)
 class GeM(nn.Module):
def __init__(self, p=3, eps=1e-6):
super(GeM,self ).__init__()
self.p = Parameter(torch.ones(1)*p)
 self.eps = eps
def forward(self, x):
return gem(x, p=self.p, eps=self.eps)
 def __repr__(self):
return self.__class__.__name__ + '(' + 'p=' + '{:.4f}'.format(self.p.data.tolist() [0])+ ', ' + 'eps=' + str(self.eps)+ ')'
class SwishImplementation(torch.autograd.Function):
@staticmethod
def forward(ctx, i):
result = i * torch.sigmoid(i)
 ctx.save_for_backward(i)
 return result
@staticmethod
def backward(ctx, grad_output):
i = ctx.saved_variables[0]
sigmoid_i = torch.sigmoid(i)
 return grad_output *(sigmoid_i *(1 + i *(1 - sigmoid_i)))
 class MemoryEfficientSwish(nn.Module):
def forward(self, x):
return SwishImplementation.apply(x)
 class Swish(nn.Module):
def forward(self, x):
return x * torch.sigmoid(x)
 class isupnet(nn.Module):
def __init__(self, num_classes,base_model, **kwargs):
super(isupnet, self ).__init__()
self.base_model_name=base_model
self.avg_pooling=GeM(p=3)
 self.max_pooling=nn.AdaptiveMaxPool2d(1)
 if base_model[0]=='e':
self.base = EfficientNet.from_name(base_model)
 feature = self.base._fc.in_features
else:
base_net=torch.hub.load('facebookresearch/semi-supervised-ImageNet1K-models', 'resnext50_32x4d_ssl')
 feature = base_net.fc.in_features
self.base=nn.Sequential(*list(base_net.children())[:-2])
 self.fc = nn.Linear(in_features=2*feature,out_features=feature,bias=True)
 self.classifiers = nn.Linear(in_features=feature, out_features=num_classes)
 self.sigmoid = MemoryEfficientSwish()
self.dropout=nn.Dropout(0.4)
 self.bn=nn.BatchNorm1d(feature)
 def freeze_base(self):
for p in self.base.parameters() :
p.requires_grad = False
def unfreeze_all(self):
for p in self.parameters() :
p.requires_grad = True
def forward(self, x1):
bs=x1.size(0)
 if self.base_model_name[0]=='e':
x2 = self.base.extract_features(x1)
 feat1=self.avg_pooling(x2)
 feat2=self.max_pooling(x2)
 feat1=feat1.view(bs,-1)
 feat2=feat2.view(bs,-1)
 feat=torch.cat([feat1,feat2],1)
 feat = self.fc(feat)
 feat = self.dropout(feat)
 ys = self.classifiers(feat)
 else:

 x=self.base(x1)
 feat1=self.avg_pooling(x)
 feat2=self.max_pooling(x)
 feat1=feat1.view(bs,-1)
 feat2=feat2.view(bs,-1)
 feat=torch.cat([feat1,feat2],1)
 feat = self.fc(feat)
 feat = self.dropout(feat)
 ys = self.classifiers(feat)
 return ys
<load_from_csv><EOS> 
if __name__ == '__main__':
use_gpu = torch.cuda.is_available()
if use_gpu:
cudnn.benchmark = True
torch.cuda.manual_seed_all(0)
 else:
print("Currently using CPU(GPU is highly recommended)")
 transform2 = transforms.Compose([
transforms.ToTensor() ,
transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]),
])
 test_data=panda_dataset(content,transform2)
 net = EfficientNet.from_name('efficientnet-b0')
 feature = net._fc.in_features
net._fc = nn.Linear(in_features=feature,out_features=6,bias=True)
 net._avg_pooling=GeM()
net1 = EfficientNet.from_name('efficientnet-b0')
 feature = net1._fc.in_features
net1._fc = nn.Linear(in_features=feature,out_features=6,bias=True)
 net1._avg_pooling=GeM()
net2 = EfficientNet.from_name('efficientnet-b0')
 feature = net2._fc.in_features
net2._fc = nn.Linear(in_features=feature,out_features=6,bias=True)
 net2._avg_pooling=GeM()
net3 = EfficientNet.from_name('efficientnet-b0')
 feature = net3._fc.in_features
net3._fc = nn.Linear(in_features=feature,out_features=6,bias=True)
 net3._avg_pooling=GeM()
net4 = EfficientNet.from_name('efficientnet-b0')
 feature = net4._fc.in_features
net4._fc = nn.Linear(in_features=feature,out_features=6,bias=True)
 net4._avg_pooling=GeM()
net5 = EfficientNet.from_name('efficientnet-b0')
 feature = net5._fc.in_features
net5._fc = nn.Linear(in_features=feature,out_features=6,bias=True)
 net5._avg_pooling=GeM()
net6 = EfficientNet.from_name('efficientnet-b0')
 feature = net6._fc.in_features
net6._fc = nn.Linear(in_features=feature,out_features=6,bias=True)
 net6._avg_pooling=GeM()
net7 = EfficientNet.from_name('efficientnet-b0')
 feature = net7._fc.in_features
net7._fc = nn.Linear(in_features=feature,out_features=6,bias=True)
 net7._avg_pooling=GeM()
nets=[net,net1,net2,net3,net4,net5,net6,net7]

 if use_gpu:
net=net.cuda()
net1=net1.cuda()
net2=net2.cuda()
net3=net3.cuda()
net4=net4.cuda()
net5=net5.cuda()
net6=net6.cuda()
net7=net7.cuda()
net.load_state_dict(load_para_dict('/kaggle/input/pandamodels/model_combine_efficientnet-b0_0.00032_adam_4_bce_karmax_gem_1536_augt_845_kar8731.pkl'))
net1.load_state_dict(load_para_dict('/kaggle/input/pandamodels/model_36_256_256_efficientnet-b0_0.0003_adam_3_bce_maxest_aug_gem_8624.pkl'))
net2.load_state_dict(load_para_dict('/kaggle/input/pandamodels/model_36_256_256_efficientnet-b0_0.0003_adam_1_bce_maxest_gem_8647.pkl'))
net3.load_state_dict(load_para_dict('/kaggle/input/pandamodels/model_36_256_256_efficientnet-b0_0.00032_adam_4_bce_maxest_aug_gem_8616.pkl'))
net4.load_state_dict(load_para_dict('/kaggle/input/pandamodels/model_36_256_256_efficientnet-b0_0.00032_adam_4_bce_maxest_augb_gem_867.pkl'))
net5.load_state_dict(load_para_dict('/kaggle/input/pandamodels/model_256_efficientnet-b0_0.00032_adam_4_bce_karmax_gem_1536_augb_kar8843_8647.pkl'))
net6.load_state_dict(load_para_dict('/kaggle/input/pandamodels/model_combine_efficientnet-b0_0.00032_adam_4_bce_karmax_gem_1536_naugt_nbal_kar8928_8725.pkl'))
net7.load_state_dict(load_para_dict('/kaggle/input/pandamodels/model_256_efficientnet-b0_0.00032_adam_0_bce_karmax_gem_1536_augb_kar8741_8567.pkl'))
print(net._avg_pooling.p)
 dataloader_test=DataLoader(
 test_data,batch_size=1, shuffle = False, num_workers= 5)
 idx=0
max_correct=0
with open('/kaggle/working/submission.csv',"a+", newline='')as f:
f_csv = csv.writer(f)
 f_csv.writerow(['image_id','isup_grade'])
 with torch.no_grad() :
net.eval()
net1.eval()
net2.eval()
net3.eval()
net4.eval()
net5.eval()
net6.eval()
net7.eval()
total=0
total_loss=0
correct=0
for id,item in enumerate(dataloader_test):
print('id ',id)
 name,datas,datas_com=item
if use_gpu:
for i in range(len(datas)) :
datas[i]=datas[i].cuda()
datas_com[i]=datas_com[i].cuda()
print(datas[0].size())
 outs=[]
for i in range(len(nets)) :
if i==0 or i== 6:
for j in range(len(datas_com)) :
outs.append(nets[i](datas_com[j]))
else:
for j in range(len(datas_com)) :
outs.append(nets[i](datas[j]))
out=outs[0]
for i in range(1,len(outs)) :
out=out+outs[i]
out=out/len(outs)
 print(out)
 predicted=get_preds(( torch.sigmoid(out)> 0.5 ).cpu().numpy())
 hh=[str(name[0]),str(predicted[0])]
print(hh)
 with open('/kaggle/working/submission.csv',"a+", newline='')as f:
f_csv = csv.writer(f)
 f_csv.writerow(hh)
 print(pd.read_csv('/kaggle/working/submission.csv' ).isup_grade.value_counts())