text stringlengths 1 93.6k |
|---|
实际输出,_=model_判断状态(图片张量.unsqueeze(0), 操作张量.unsqueeze(0),trg_mask)
|
_, 抽样 = torch.topk(实际输出, k=1, dim=-1)
|
抽样np = 抽样.cpu().numpy()
|
optimizer.zero_grad()
|
实际输出 = 实际输出.view(-1, 实际输出.size(-1))
|
loss = F.cross_entropy(实际输出, 目标输出.contiguous().view(-1), ignore_index=-1)
|
print('轮', i, '实际输出', 状态列表[抽样np[0, 0, 0, 0]], '目标输出', 全部数据[key],loss)
|
loss.backward()
|
optimizer.step()
|
torch.save(model_判断状态.state_dict(), 'weights/model_weights_判断状态L')
|
torch.save(model_判断状态.state_dict(), 'weights/model_weights_判断状态L{}'.format(str(i)))
|
# <FILESEP>
|
#!/usr/bin/env python
|
import sys
|
import time
|
import serial
|
from threading import Thread
|
class RawInput:
|
"""Gets a single character from standard input. Does not echo to the screen."""
|
def __init__(self):
|
try:
|
self.impl = RawInputWindows()
|
except ImportError:
|
self.impl = RawInputUnix()
|
def __call__(self): return self.impl()
|
class RawInputUnix:
|
def __init__(self):
|
import tty, sys
|
def __call__(self):
|
import sys, tty, termios
|
fd = sys.stdin.fileno()
|
old_settings = termios.tcgetattr(fd)
|
try:
|
tty.setraw(sys.stdin.fileno())
|
ch = sys.stdin.read(1)
|
finally:
|
termios.tcsetattr(fd, termios.TCSADRAIN, old_settings)
|
return ch
|
class RawInputWindows:
|
def __init__(self):
|
import msvcrt
|
def __call__(self):
|
import msvcrt
|
return msvcrt.getch()
|
class Baudrate:
|
VERSION = '1.0'
|
READ_TIMEOUT = 5
|
BAUDRATES = [
|
# "1200",
|
# "1800",
|
# "2400",
|
# "4800",
|
"9600",
|
"38400",
|
"19200",
|
"57600",
|
"115200",
|
]
|
UPKEYS = ['u', 'U', 'A']
|
DOWNKEYS = ['d', 'D', 'B']
|
MIN_CHAR_COUNT = 25
|
WHITESPACE = [' ', '\t', '\r', '\n']
|
PUNCTUATION = ['.', ',', ':', ';', '?', '!']
|
VOWELS = ['a', 'A', 'e', 'E', 'i', 'I', 'o', 'O', 'u', 'U']
|
def __init__(self, port=None, threshold=MIN_CHAR_COUNT, timeout=READ_TIMEOUT, name=None, auto=True, verbose=False):
|
self.port = port
|
self.threshold = threshold
|
self.timeout = timeout
|
self.name = name
|
self.auto_detect = auto
|
self.verbose = verbose
|
self.index = len(self.BAUDRATES) - 1
|
self.valid_characters = []
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.