通过机器人登录 Telegram WebApp 时,出现错误:Upstream connection error: unable to verify the first certificate
。此外,如果您从浏览器或其他设备发出请求,一切都可以。该网站通过 nginx 提供服务
主页
/
user-563758
Lwich's questions
不起作用QScrollArea
,基本上不会出现。
帮助我理解为什么它不起作用?
import sys
import asyncio
from PyQt6.QtCore import QSize, Qt, QRect
from PyQt6.QtWidgets import QApplication, QMainWindow, QHBoxLayout, \
QWidget, QVBoxLayout, QPushButton, QLineEdit, QScrollArea, QLabel, \
QGridLayout
from parser.db import get_data_by_condition
class Window(QMainWindow):
def __init__(self) -> None:
super().__init__()
self.init_ui()
def init_ui(self):
self.add_button = QPushButton('Добавить')
self.add_button.clicked.connect(self.parse_data)
self.model = QLineEdit()
self.detail = QLineEdit()
self.article = QLineEdit()
input_layout = QHBoxLayout()
input_layout.setSpacing(12)
input_layout.addWidget(self.add_button)
input_layout.addWidget(self.model)
input_layout.addWidget(self.detail)
input_layout.addWidget(self.article)
input_widget = QWidget()
input_widget.setLayout(input_layout)
layout = QVBoxLayout()
container = QWidget()
self.scroll_layout = QVBoxLayout(container)
self.scroll_layout.addWidget(input_widget)
self.scroll_area = QScrollArea(container)
self.scroll_area.resize(900, 250)
self.scroll_area.setWidgetResizable(True)
self.scroll_widget = QWidget()
self.scroll_widget.setGeometry(QRect(0, 0, 380, 280))
self.scroll_layout_2 = QVBoxLayout(self.scroll_area)
self.grid_layout = QGridLayout()
self.scroll_layout_2.addLayout(self.grid_layout)
self.scroll_area.setWidget(self.scroll_widget)
self.scroll_layout.addWidget(self.scroll_area)
container.setLayout(layout)
self.setCentralWidget(container)
def parse_data(self):
model = self.model.text()
article = self.article.text()
detail = self.detail.text()
loop = asyncio.new_event_loop()
objects = loop.run_until_complete(get_data_by_condition(article, detail))
loop.close()
for obj in objects[:40]:
label = QLabel(f'{obj[0]} {obj[1]} {obj[2]} {obj[3]} {obj[4]} {obj[5]}')
label.setFixedHeight(20)
self.grid_layout.addWidget(label)
app = QApplication(sys.argv)
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
window = Window()
window.setFixedSize(QSize(900, 400))
window.show()
if __name__ == '__main__':
app.exec()
我刚刚开始研究神经网络。在解决XOR问题时,我遇到了一个总是给我0.5的问题
import random
def sigmoid(x):
return 1 / (1 + math.exp(-x))
def dot(l1, l2):
s = 0
for i in range(len(l1)):
s += l1[i] * l2[i]
return s
INPUTS = [[0, 0], [1, 1], [0, 1], [1, 0]]
OUTPUT = [0, 0, 1, 1]
weights = [random.random(), random.random()]
for _ in range(10_000):
for i in range(len(INPUTS)):
layer_input = INPUTS[i]
output = sigmoid(dot(layer_input, weights))
err = OUTPUT[i] - output
delta = err * (output * (1 - output))
grad1 = layer_input[0] * delta
grad2 = layer_input[1] * delta
weights[0] += grad1
weights[1] += grad2
print(sigmoid(dot([0, 0], weights))) # 0.5
尝试使用 numpy,同样的事情