This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try: | |
pincodefieldobj = WebDriverWait(browser, delay).until(EC.presence_of_element_located((By.XPATH, pincodefield))) | |
pincodefieldobj.send_keys(pin) | |
loginsubmitobj = WebDriverWait(browser, delay).until(EC.presence_of_element_located((By.XPATH, login_submit))) | |
loginsubmitobj.click() | |
age18p = WebDriverWait(browser, delay).until(EC.presence_of_element_located((By.XPATH, age18plus))) | |
age18p.click() | |
myElem = WebDriverWait(browser, delay).until(EC.presence_of_element_located((By.XPATH,databasepath))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
opts = Options() | |
opts.add_argument('--headless') | |
browser = webdriver.Firefox(firefox_options=opts,executable_path='./geckodriver') | |
browser.get(website) | |
browser.find_element_by_xpath(searchbypin).click() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from selenium import webdriver | |
from selenium.webdriver.support.ui import WebDriverWait | |
from selenium.webdriver.support import expected_conditions as EC | |
from selenium.webdriver.common.by import By | |
from selenium.common.exceptions import TimeoutException | |
from bs4 import BeautifulSoup | |
from selenium.webdriver.firefox.options import Options | |
import time | |
import pandas as pd | |
from call import * |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from twilio.rest import TwilioRestClient | |
def dial(): | |
TWILIO_PHONE_NUMBER = "<your twilio trial number>" | |
number = "<your number that you have already verified>" | |
TWIML_INSTRUCTIONS_URL ="https://gist.githubusercontent.com/thunderInfy/5fffbe366e990a2b057b872cfa49db73/raw/c8edb2b4ef044fb3806e3bb5ec459e08c1cecac1/twiml.xml" | |
client = TwilioRestClient(<Account SID>, <AUTH TOKEN>) | |
client.calls.create(to=number, from_=TWILIO_PHONE_NUMBER, url=TWIML_INSTRUCTIONS_URL, method="GET") | |
if __name__ == "__main__": |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<Response> | |
<Hangup/> | |
</Response> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
τ = 0.05 | |
def loss_function(q, k, queue): | |
# N is the batch size | |
N = q.shape[0] | |
# C is the dimensionality of the representations | |
C = q.shape[1] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# update resnetk | |
for θ_k, θ_q in zip(resnetk.parameters(), resnetq.parameters()): | |
θ_k.data.copy_(momentum*θ_k.data + θ_q.data*(1.0 - momentum)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# update the queue | |
queue = torch.cat((queue, k), 0) | |
# dequeue if the queue gets larger than the max queue size - denoted by K | |
# batch size is 256, can be replaced by a variable | |
if queue.shape[0] > K: | |
queue = queue[256:,:] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# get loss value | |
loss = loss_function(q, k, queue) | |
# put that loss value in the epoch losses list | |
epoch_losses_train.append(loss.cpu().data.item()) | |
# perform backprop on loss value to get gradient values | |
loss.backward() | |
# run the optimizer |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# zero out grads | |
optimizer.zero_grad() | |
# retrieve xq and xk the two image batches | |
xq = sample_batched['image1'] | |
xk = sample_batched['image2'] | |
# move them to the device | |
xq = xq.to(device) | |
xk = xk.to(device) |