如何在Hasura数据api中编写postgres sql主体,以获取用户输入的结果。 sql查询类似于“从表名中选择moviedetails,其中movie_name ='用户输入的名称'。我想知道接受用户数据的结构
url = "https://data.incipiently69.hasura-app.io/v1/query"
requestPayload = { “type”:“select”, “args”:{ “表”:“收集”, “列”: [ “概览” ] } }
headers = { “Content-Type”:“application / json” }
resp = requests.request(“POST”,url,data = json.dumps(requestPayload),headers = headers)
打印(resp.content)
答案 0 :(得分:1)
您只需要在API查询的where子句中替换从用户输入中检索到的数据。
# Step 1: Compute the (encoding) distance between the anchor and the positive, you will need to sum over axis=-1
pos_dist = tf.square(tf.abs(tf.subtract(anchor,positive)))
# Step 2: Compute the (encoding) distance between the anchor and the negative, you will need to sum over axis=-1
neg_dist = tf.square(tf.abs(tf.subtract(anchor,negative)))
# Step 3: subtract the two previous distances and add alpha.
basic_loss = tf.subtract(pos_dist,neg_dist) + alpha
# Step 4: Take the maximum of basic_loss and 0.0. Sum over the training examples.
#printing the first 5 elements to debug
print(basic_loss[0,0:5].eval())
print(tf.maximum(basic_loss[0,0:5].eval(),0).eval())
loss = tf.reduce_sum(tf.maximum(basic_loss,0.0))