text
stringlengths 1
93.6k
|
|---|
trainloader = getloader(opt)
|
model = get_arch(opt)
|
print_network(model)
|
optimizer = optim.Adam(model.parameters(), lr=opt.lr, betas=(0.9, 0.999))
|
scheduler = MultiStepLR(optimizer, milestones=opt.milestone, gamma=0.1)
|
######### DataParallel ###########
|
model = torch.nn.DataParallel(model)
|
model.cuda()
|
ssimloss = SSIM().cuda()
|
run_loss = 0.0
|
global_step = 0
|
print("Start training!")
|
batch_num = 0
|
for epoch in range(opt.nepochs):
|
print("####### Epoch:%d starts #######" %(epoch + 1))
|
Dis_start = time.time()
|
for train_x, train_y in trainloader:
|
global_step += 1
|
train_x = train_x.cuda()
|
train_y = train_y.cuda()
|
optimizer.zero_grad()
|
out = model(train_x)
|
loss = -1 * ssimloss(out, train_y)
|
loss.backward()
|
optimizer.step()
|
batch_num += 1
|
run_loss += loss.item()
|
if global_step % opt.dis_freq == 0:
|
Dis_end = time.time()
|
print("|Epoch:%d, global step:%d, loss:%.3f time:%.3f|" %(epoch+1, global_step, run_loss/opt.dis_freq,
|
Dis_end - Dis_start))
|
run_loss = 0.0
|
Dis_start = Dis_end
|
scheduler.step()
|
torch.save(model.state_dict(), os.path.join(savepath, 'net_latest.pth'))
|
if (epoch + 1) % opt.save_freq == 0:
|
torch.save(model.state_dict(), os.path.join(savepath,
|
'net_epoch_%d.pth' % (epoch + 1)))
|
# <FILESEP>
|
# -*- coding: utf-8 -*-
|
import logging
|
from websocket_fuzzer.main.websocket_wrapper import send_payloads_in_websocket
|
#
|
# Configure logging
|
#
|
logging.basicConfig(level=logging.DEBUG,
|
format='[%(asctime)s][%(levelname)-8s] %(message)s',
|
datefmt='%m-%d %H:%M',
|
filename='output.log',
|
filemode='w')
|
console = logging.StreamHandler()
|
console.setLevel(logging.DEBUG)
|
formatter = logging.Formatter('[%(asctime)s][%(levelname)-8s] %(message)s')
|
console.setFormatter(formatter)
|
logging.getLogger('').addHandler(console)
|
#
|
# User configured parameters
|
#
|
# The websocket address, including the protocol, for example:
|
#
|
# ws://localhost
|
# wss://localhost
|
#
|
ws_address = ''
|
# The proxy server used to send the messages. This is very useful
|
# for debugging the tools
|
http_proxy_host = 'localhost'
|
http_proxy_port = '8080'
|
# Log path, all messages are logged in different files
|
log_path = 'output/'
|
# Websocket authentication message. The tool will send the authentication
|
# message (if included in messages below) and wait for `session_active_message`
|
# before sending `message`
|
auth_message = ''
|
session_active_message = ''
|
# The message to send to the websocket
|
message = ''
|
# The list containing all messages to be sent to the websocket. In some cases
|
# You need to send two or more messages to set a specific remote state, and
|
# then you send the attack
|
messages = [
|
auth_message,
|
message,
|
]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.