def bot(): name = input('Enter your name here : ') greeting(name) introduction() input_data() print('Do you want to know about something else..', '1.YES', '2.NO', sep='\n') choice = int(input('Enter your choice : ')) while choice == 1: input_data() print('Do you want to know about something else..', '1.YES', '2.NO', sep='\n') choice = int(input('Enter your choice : ')) if choice == 2: print('Hope this is useful', 'Thankyou for coming here ..🤗🤗', sep='\n')
def __init__(self, args): super(Model_Run, self).__init__() for k, v in vars(args).items(): setattr(self, k, v) self.args = args self.data_generator = input_data(args) p_content = self.data_generator.p_content word_embed = self.data_generator.word_embed self.model = SHNE_Encoder(args, p_content, word_embed) # run with GPU if self.args.cuda: self.model.cuda() # setting optimizer self.parameters = filter(lambda p: p.requires_grad, self.model.parameters()) self.optim = optim.Adam(self.parameters, lr=self.lr, weight_decay=0.0)
def __initData(self, file_number): inp = data.input_data() #Read files with open(inp[self.file_number] + ".kp") as level_file: rows = level_file.read().split('\n') print(rows[0]) number_of_items = (int)(rows[1]) self.items = [] self.file_name = inp[self.file_number - 1] for i in range(4, number_of_items + 5 - 1): x = rows[i].split(" ")[0] y = rows[i].split(" ")[1] self.items.append(((int)(x), (int)(y))) self.maxCapacity = (int)(rows[2])
parser.add_argument( '--data-valid', default="/home/hemant/net/easy_net/data/val/", help= 'enter the directory where the validation data of different classes is saved' ) parser.add_argument( '--data-train', default="/home/hemant/net/easy_net/data/train/", help= 'enter the directory where the train data of different classes is saved') parser.add_argument("--pll", action='store_true', help='use multi-gpu or no') parser.add_argument("--weights", action='store_true', help='use weights or no') args = parser.parse_args() input_train = input_data(root_dir=args.data_train, type="train") train_dl = DataLoader(input_train, batch_size=args.batch_size, shuffle=True, num_workers=4) input_valid = input_data(root_dir=args.data_valid, type="valid") valid_dl = DataLoader(input_valid, batch_size=args.batch_size * 2, shuffle=False, num_workers=4) if __name__ == '__main__': model = nn.Sequential(feature_b(), feature_r(), decision(out_classes=input_train[0][3]))
sess = tf.Session(config=config) #Placeholder x1 = tf.placeholder(tf.float32, [batch_size, Height, Width, Channel]) x2 = tf.placeholder(tf.float32, [batch_size, Height, Width, Channel]) x3 = tf.placeholder(tf.float32, [batch_size, Height, Width, Channel]) ## MC-subnet x1to2 = flow.warp_img(batch_size, x2, x1, False) x3to2 = flow.warp_img(batch_size, x2, x3, True) ## QE-subnet x2_enhanced = net.network(x1to2, x2, x3to2) ##Import data PQF_Frame_93_Y, PQF_Frame_93_U, PQF_Frame_93_V = data.input_data( Height, Width, 'Frame_93') non_PQF_Frame_96_Y, non_PQF_Frame_96_U, non_PQF_Frame_96_V = data.input_data( Height, Width, 'Frame_96') PQF_Frame_97_Y, PQF_Frame_97_U, PQF_Frame_97_V = data.input_data( Height, Width, 'Frame_97') ##Load model saver = tf.train.Saver() saver.restore(sess, './HEVC_QP37_model/model.ckpt') ##Run test Enhanced_Y = sess.run(x2_enhanced, feed_dict={ x1: PQF_Frame_93_Y[0:1, 0:Height, 0:Width, 0:1], x2: non_PQF_Frame_96_Y[0:1, 0:Height, 0:Width, 0:1], x3: PQF_Frame_97_Y[0:1, 0:Height, 0:Width, 0:1]
def main(): #from 1 to 12 # print('Input folder to run (1->13): ', end = '') # folder_to_run = int(input()) inp = data.input_data() check_point = 28 # for name in range((folder_to_run - 1)*8, (folder_to_run - 1)*8 + 8): for name in range(check_point, len(inp)): #Declare time start = time.time() elapsed = 0 print('File name: ' + inp[name]) print('Package number: ' + str(name)) with open(inp[name] + ".kp") as level_file: rows = level_file.read().split('\n') number_items = (int)(rows[1]) capacities = [(int)(rows[2])] values = [] weights = [[]] for i in range(4, number_items + 5 - 1): x = rows[i].split(" ")[0] y = rows[i].split(" ")[1] values.append((int)(x)) weights[0].append((int)(y)) solver = pywrapknapsack_solver.KnapsackSolver( pywrapknapsack_solver.KnapsackSolver.KNAPSACK_MULTIDIMENSION_BRANCH_AND_BOUND_SOLVER, 'KnapsackExample') #Set time limit - seconds #3 minutes -> 180 seconds solver.set_time_limit(180) solver.Init(values, weights, capacities) computed_value = solver.Solve() packed_items = [] packed_weights = [] total_weight = 0 for i in range(len(values)): if solver.BestSolutionContains(i): packed_items.append(i) packed_weights.append(weights[0][i]) total_weight += weights[0][i] elapsed = time.time() - start # print("Capacity = {}\nTotal weight = {} \nTotal value = {} \nNumber of items: {} \n " \ # .format(capacities[0], total_weight, computed_value, len(packed_items))) with open("output/Google-OR-Tools/" + "test " + str(name) + ".txt", 'w+') as solver_file: solver_file.write('File name: {}.kp\nExecution time: {} sec\nCapacity = {} \nTotal weight = {} \nTotal value = {} \nNumber of items: {} \n' \ .format(inp[name], elapsed, capacities[0], total_weight, computed_value, len(packed_items))) # solver_file.write('Execution time: {} sec\n'.format(elapsed)) # solver_file.write('Capacity = {} \n'.format(str(capacities[0]))) # solver_file.write('Total weight = {} \n'.format(str(total_weight))) # solver_file.write('Total value = {} \n'.format(computed_value)) # solver_file.write('Number of items: {} \n'.format(str(len(packed_items)))) # solver_file.write('Packed items: {} \n'.format(packed_items)) # solver_file.write('Packed weights: {}'.format(len(packed_items))) print('Execution time: ' + str(elapsed)) # print('Capacity = ' + str(capacities[0])) # print('Total weight = ' + str(total_weight)) # print('Number of items: ' + str(len(packed_items))) # print('Packed items:', packed_items) # print('Packed_weights:', packed_weights) print()