def Torrent(itorrent, dir1, dir2, idelta, dirD, files): torrent = opentorrent(itorrent) sfiles = [] d = 0 files = sortByFiles(files) for i in files: S = True df1 = os.path.join(dir1, i[0]) df2 = os.path.join(dir2, i[1]) if not os.path.isfile(df1): print("File not found: {}".format(i[0])) S = False if not os.path.isfile(df2): print("File not found: {}".format(i[1])) S = False if not fileintorr(torrent, i[0]): print("File not found in torrent: {}".format(i[0])) S = False if S: execute('xdelta3 -e -s "{}" "{}" "{}.delta"'.format(df1, df2, d)) sfiles.append({ 'file1': i[0], 'file2': i[1], 'delta': Delta("d.delta".format(d), idelta, i[0], i[1]) }) d += 1 CDelta(sfiles, dirD, dir2)
def __init__(self, robot: str): # Thread-safe event flags self.program_stopped = Event() self.ignore_controller = Event() self._current_mode = 'off' self.controller = None self.already_connected = False self.controller_poll_rate = 5 self.mode_poll_rate = 0.1 self.mode_lock = RLock() self.lcd = LCD() # Preprocess string robot_str = robot.strip().lower() if robot_str == '6rus': self.robot = SixRUS(stepper_mode=1 / 32, step_delay=0.002) elif robot_str == 'quattro': self.robot = Quattro(stepper_mode=1 / 32, step_delay=0.002) elif robot_str == 'delta': self.robot = Delta(stepper_mode=1 / 32, step_delay=0.002) else: raise ValueError(f"Unknown robot type: {robot}") self.lcd.print_status(f'Started {robot}')
import random from Delta import Delta from Active_Function import Sigmoid count_Training_Data = 4 count_Node = 1 X = [[0, 0, 1], [0, 1, 1], [1, 0, 1], [1, 1, 1]] D = [0, 0, 1, 1] Weight = list() for i in range(0, 3): Weight.append(random.uniform(-1, 1)) bias = [0] Learning_rate = 0.9 for epoch in range(0, 10000): Delta("SGD", Learning_rate, Sigmoid, bias, Weight, X, D, count_Training_Data, count_Node) for k in range(0, count_Training_Data): v = 0 for W_count in range(0, len(Weight)): x = X[k][W_count] v = v + (Weight[W_count] * x + 0) print(Sigmoid(v, False))
import random from Delta import Delta, Sigmoid #N = int(input("학습데이터의 수: ")) count_Training = 4 # 학습데이터의 수 count_Node = 1 # 1. 데이터 입력 X = [[0, 0, 1], [0, 1, 1], [1, 0, 1], [1, 1, 1]] D = [0, 0, 1, 1] Weight = list() for i in range(0, 3): # 노드의 입력값들의 가중치 count Weight.append(random.uniform(-1, 1)) # 가중치 랜덤값으로 초기화 bias = [0] Learning_rate = 0.9 #학습률(0<alpha<=1), 크면 수렴하지 못함, 작으면 정답에 근접속도가 느림 for epoch in range(0, 10000): # SGD 방식 Delta(Learning_rate, Sigmoid, bias, Weight, X, D, count_Training, count_Node) #활성함수(시그모이드)를 델타 규칙으로 학습 for k in range(0, count_Training): v = 0 for W_count in range(0, len(Weight)): x = X[k][W_count] #학습데이터의 입력데이터 #v = W*x+0 #노드의 가중합(가중행렬*입력데이터+bias) #의도가 담긴 방향성 v = v + (Weight[W_count] * x + 0) # 최종v = v + 0(행렬계산 + bias) print(Sigmoid(v, False))