검색
아하에서 찾은 849건의 질문
- 생활꿀팁생활Q. 랜섬웨어에 걸린것 같습니다 어떻게 해야하나요?어떤 것을 다운로드하다가 걸린것같아요 아마도 랜섬웨어일것같아요바탕화면이 파란 도트로 다 찍혀져있고 바탕화면 위쪽에는 영어로 써있는데 해석해보니까 파일이 다 암호화되고 40i어쩌고였나 하는 메모를 봐서 해결하라는데 그메모를 제가 삭제했어요 랜섬웨어 이름과 해결법 알려주세요글고 포맷 하면 나아지나요?
- 생활꿀팁생활Q. 잘되던컴퓨터갑자기모니터인식이안될때어떻게하나요?컴퓨터새로산지4개월밖에 안되는 성는좋은 i-9세대 윈도우10 입니다이것저것 그래픽작업도 해야되서 와콤씬틱모니터1개와일반모니터 2개를더해서 총3개의모니터를연결해서 쓰고 있었는데어제까지잘되던컴퓨터가 갑자기 전부다 인식이안되네요 선을바꿔껴봐도 안되고 부팅을하면 본채는(파워포함모든팬들도정상적으로)잘돌아가는데 모니터느 그저 no signal.. 어떻하면좋을까요?ㅠㅠ
- 기타 고민상담고민상담Q. 내향적인 사람과 외향적인 사람 두 그룹의 소득수준 차이의 이유는 ?몇 년 전부터 유행했었던 mbti에서 E(외향)인 사람들의 소득 평균이 I(내향)인 사람들과 비교했을때에 대부분의 E인 사람들이 전반적으로 더 높은 소득수준을 보이더군요. 현대사회는 사회와 집단 그 개개인들이 이루고 있고 자유로운 거래와 시장경제가 기반을 이루기에 당연히 사회적으로 외향적인 사람들이 소득수준이 더 높다고 생각될 듯 싶지만, 결국엔 회사원이나 서비스직 종사자나 생산, 기술자나 전부 물질적인 것이든 물질적이지 않든 어떠한 가치가 있는 것을 (자료, 정보, 서비스, 물건) 생산하거나 제공하거나 혹은 스스로가 가치를 띄는 무언가가 되어서 돈을 버는 것 같은데, 여기서 궁금한 것은 제 생각에는 단순히 외향적이라는 것은 사람들과 잘 어울린다 뿐만 있는 것은 아닌 것 같습니다. 비즈니스 관계에서 내향적인 사람들 보다야 이점을 가지고 (거래의 기회 증가), 혹은 폭넓은 인간관계에서 오는 나의 업무나 나에 관한 가치평가 상승 정도는 기대할 수 있겠지만 이것들이 극명하게 소득수준이 갈릴만한 요인의 전부인 것 같지는 않습니다. 제 경험상으론 외향적인 사람들이 조금더 보편적으로 생각한다던가 아니면, 유별난 생각이 있어도 보편적으로 행동하는 모습을 많이 봤었습니다 (옷, 취향 스타일이 아님. 조금더 근본적인?). 외향적인 사람과 내향적인 사람들의 소득수준이 차이가 날 수 밖에 없는 이유는 무엇일까요?
- 생활꿀팁생활Q. [파이썬]이 두 코드가 무슨 차인지 알고 싶어요.class Mylist(list): def replace(self, old, new): for i in self: if i == old: self[self.index(i)] = new return a = Mylist([1, 2, 3, 4, 5]) a.replace(2, 4) a ----결과--- [1, 4, 3, 4, 5]class Mylist(list): def replace(self, old, new): new_list = list(map(lambda x : new if x == old else x, self)) self = new_list a = Mylist((1, 2, 3, 4, 5)) a.replace(2, 4) a ---결과--- [1, 2, 3, 4, 5]제가볼땐 위의 코드와 아래의 코드가 같은 결과값이 나와야 한다고 생각하는데.. 왜 기존의 self 에 new list가 할당이 안되나요? ㅠ 뭔가 스코프를 놓치고 있는 것 같은데 궁금합니다!
- 기타 고민상담고민상담Q. 저의 모습은 외향일까요 내향일까요?MBTI는 E와 I가 비슷하지만 E가 쪼금더 높게 나왔어요. 그리고 실제로 낯선이들과도 잘어울리구요.예를 들자면 게스트하우스같은 곳에 가서 잘어울리고 일명 인싸기질이 있긴해요. 근데 평상시에는 전화도 잘 받지 않구요. 오히려 전화가 오면 무서워요.택배,음식배달 같은 낯선 사람과 몇 초 눈마주치는 것도 부담스러워요. 다른 사람들이 저에대해 물어보는게 두렵구요. 어떨땐 제가 집단에서 주도하고 리드하는 경향이 보이기도하는데, 어떨때는 그냥 숨으려고하는 모습...어떤게 저의 진짜모습일까요...
- 생활꿀팁생활Q. TPM 모듈과 ST MICRO 간 SPI 통신 방법이 궁금합니다.두서없이 바로 본문으로 넘어가 질문하는 점 죄송합니다 ㅠST MICRO(master) 에서 보내는 데이터는char a[] = "011111110001101000011000001000001234567890123456789012345678901";이며,HAL 함수는uint8_t b[64] = { 0x00 };if (HALSPITransmitReceive(&hspi2, a, b, 64, 10) == HALOK) { HAL_Delay(1000); printf("\n--------------------1-----------------\n"); for (int i = 0; i < 64; i++) { printf(" %02x", a[i]); } HAL_Delay(1000); printf("\n--------------------1-----------------end\n"); for (int i = 0; i < 64; i++) { printf(" %02x", b[i]); }}로 작성하여 TPM(Slave) 으로 송신하는 데이터와 수신되는 데이터를 터미널로 찍어보고 있습니다.송신 데이터는 잘 가는거 같은데결과값이 쓰레기값 또는 0 또는 255로 채워져서 수신되고 있습니다.TPM 에서 spi 프로토콜을 지원한다고 하고 있으나, 단순한 샘플 예시조차 없어서 어떻게 접근해야되는지를 모르겠습니다.
- 생활꿀팁생활Q. 파이썬 코드 idle python 에서 오류?안녕하세요 제가 코딩을 공부하던중 http://solarisailab.com/archives/486 의 코드를 사용하였습니다코드는""" TensorFlow translation of the torch example found here (written by SeanNaren). https://github.com/SeanNaren/TorchQLearningExample Original keras example found here (written by Eder Santana). https://gist.github.com/EderSantana/c7222daa328f0e885093#file-qlearn-py-L164 The agent plays a game of catch. Fruits drop from the sky and the agent can choose the actions left/stay/right to catch the fruit before it reaches the ground."""import tensorflow.compat.v1 as tftf.disablev2behavior()import numpy as npimport randomimport mathimport os# Parametersepsilon = 1 # The probability of choosing a random action (in training). This decays as iterations increase. (0 to 1)epsilonMinimumValue = 0.001 # The minimum value we want epsilon to reach in training. (0 to 1)nbActions = 3 # The number of actions. Since we only have left/stay/right that means 3 actions.epoch = 1001 # The number of games we want the system to run for.hiddenSize = 100 # Number of neurons in the hidden layers.maxMemory = 500 # How large should the memory be (where it stores its past experiences).batchSize = 50 # The mini-batch size for training. Samples are randomly taken from memory till mini-batch size.gridSize = 10 # The size of the grid that the agent is going to play the game on.nbStates = gridSize * gridSize # We eventually flatten to a 1d tensor to feed the network.discount = 0.9 # The discount is used to force the network to choose states that lead to the reward quicker (0 to 1) learningRate = 0.2 # Learning Rate for Stochastic Gradient Descent (our optimizer).# Create the base model.X = tf.placeholder(tf.float32, [None, nbStates])W1 = tf.Variable(tf.truncated_normal([nbStates, hiddenSize], stddev=1.0 / math.sqrt(float(nbStates))))b1 = tf.Variable(tf.truncated_normal([hiddenSize], stddev=0.01)) input_layer = tf.nn.relu(tf.matmul(X, W1) + b1)W2 = tf.Variable(tf.truncated_normal([hiddenSize, hiddenSize],stddev=1.0 / math.sqrt(float(hiddenSize))))b2 = tf.Variable(tf.truncated_normal([hiddenSize], stddev=0.01))hiddenlayer = tf.nn.relu(tf.matmul(inputlayer, W2) + b2)W3 = tf.Variable(tf.truncated_normal([hiddenSize, nbActions],stddev=1.0 / math.sqrt(float(hiddenSize))))b3 = tf.Variable(tf.truncated_normal([nbActions], stddev=0.01))outputlayer = tf.matmul(hiddenlayer, W3) + b3# True labelsY = tf.placeholder(tf.float32, [None, nbActions])# Mean squared error cost functioncost = tf.reducesum(tf.square(Y-outputlayer)) / (2*batchSize)# Stochastic Gradient Decent Optimizeroptimizer = tf.train.GradientDescentOptimizer(learningRate).minimize(cost)# Helper function: Chooses a random value between the two boundaries.def randf(s, e): return (float(random.randrange(0, (e - s) * 9999)) / 10000) + s;# The environment: Handles interactions and contains the state of the environmentclass CatchEnvironment(): def init(self, gridSize): self.gridSize = gridSize self.nbStates = self.gridSize * self.gridSize self.state = np.empty(3, dtype = np.uint8) # Returns the state of the environment. def observe(self): canvas = self.drawState() canvas = np.reshape(canvas, (-1,self.nbStates)) return canvas def drawState(self): canvas = np.zeros((self.gridSize, self.gridSize)) canvas[self.state[0]-1, self.state[1]-1] = 1 # Draw the fruit. # Draw the basket. The basket takes the adjacent two places to the position of basket. canvas[self.gridSize-1, self.state[2] -1 - 1] = 1 canvas[self.gridSize-1, self.state[2] -1] = 1 canvas[self.gridSize-1, self.state[2] -1 + 1] = 1 return canvas # Resets the environment. Randomly initialise the fruit position (always at the top to begin with) and bucket. def reset(self): initialFruitColumn = random.randrange(1, self.gridSize + 1) initialBucketPosition = random.randrange(2, self.gridSize + 1 - 1) self.state = np.array([1, initialFruitColumn, initialBucketPosition]) return self.getState() def getState(self): stateInfo = self.state fruit_row = stateInfo[0] fruit_col = stateInfo[1] basket = stateInfo[2] return fruitrow, fruitcol, basket # Returns the award that the agent has gained for being in the current environment state. def getReward(self): fruitRow, fruitColumn, basket = self.getState() if (fruitRow == self.gridSize - 1): # If the fruit has reached the bottom. if (abs(fruitColumn - basket) <= 1): # Check if the basket caught the fruit. return 1 else: return -1 else: return 0 def isGameOver(self): if (self.state[0] == self.gridSize - 1): return True else: return False def updateState(self, action): if (action == 1): action = -1 elif (action == 2): action = 0 else: action = 1 fruitRow, fruitColumn, basket = self.getState() newBasket = min(max(2, basket + action), self.gridSize - 1) # The min/max prevents the basket from moving out of the grid. fruitRow = fruitRow + 1 # The fruit is falling by 1 every action. self.state = np.array([fruitRow, fruitColumn, newBasket]) #Action can be 1 (move left) or 2 (move right) def act(self, action): self.updateState(action) reward = self.getReward() gameOver = self.isGameOver() return self.observe(), reward, gameOver, self.getState() # For purpose of the visual, I also return the state.# The memory: Handles the internal memory that we add experiences that occur based on agent's actions,# and creates batches of experiences based on the mini-batch size for training.class ReplayMemory: def init(self, gridSize, maxMemory, discount): self.maxMemory = maxMemory self.gridSize = gridSize self.nbStates = self.gridSize * self.gridSize self.discount = discount canvas = np.zeros((self.gridSize, self.gridSize)) canvas = np.reshape(canvas, (-1,self.nbStates)) self.inputState = np.empty((self.maxMemory, 100), dtype = np.float32) self.actions = np.zeros(self.maxMemory, dtype = np.uint8) self.nextState = np.empty((self.maxMemory, 100), dtype = np.float32) self.gameOver = np.empty(self.maxMemory, dtype = np.bool) self.rewards = np.empty(self.maxMemory, dtype = np.int8) self.count = 0 self.current = 0 # Appends the experience to the memory. def remember(self, currentState, action, reward, nextState, gameOver): self.actions[self.current] = action self.rewards[self.current] = reward self.inputState[self.current, ...] = currentState self.nextState[self.current, ...] = nextState self.gameOver[self.current] = gameOver self.count = max(self.count, self.current + 1) self.current = (self.current + 1) % self.maxMemory def getBatch(self, model, batchSize, nbActions, nbStates, sess, X): # We check to see if we have enough memory inputs to make an entire batch, if not we create the biggest # batch we can (at the beginning of training we will not have enough experience to fill a batch). memoryLength = self.count chosenBatchSize = min(batchSize, memoryLength) inputs = np.zeros((chosenBatchSize, nbStates)) targets = np.zeros((chosenBatchSize, nbActions)) # Fill the inputs and targets up. for i in xrange(chosenBatchSize): if memoryLength == 1: memoryLength = 2 # Choose a random memory experience to add to the batch. randomIndex = random.randrange(1, memoryLength) current_inputState = np.reshape(self.inputState[randomIndex], (1, 100)) target = sess.run(model, feeddict={X: currentinputState}) current_nextState = np.reshape(self.nextState[randomIndex], (1, 100)) currentoutputs = sess.run(model, feeddict={X: current_nextState}) # Gives us Q_sa, the max q for the next state. nextStateMaxQ = np.amax(current_outputs) if (self.gameOver[randomIndex] == True): target[0, [self.actions[randomIndex]-1]] = self.rewards[randomIndex] else: # reward + discount(gamma) * max_a' Q(s',a') # We are setting the Q-value for the action to r + gamma*max a' Q(s', a'). The rest stay the same # to give an error of 0 for those outputs. target[0, [self.actions[randomIndex]-1]] = self.rewards[randomIndex] + self.discount * nextStateMaxQ # Update the inputs and targets. inputs[i] = current_inputState targets[i] = target return inputs, targets def main(_): print("Training new model") # Define Environment env = CatchEnvironment(gridSize) # Define Replay Memory memory = ReplayMemory(gridSize, maxMemory, discount) # Add ops to save and restore all the variables. saver = tf.train.Saver() winCount = 0 with tf.Session() as sess: tf.initializeallvariables().run() for i in xrange(epoch): # Initialize the environment. err = 0 env.reset() isGameOver = False # The initial state of the environment. currentState = env.observe() while (isGameOver != True): action = -9999 # action initilization # Decides if we should choose a random action, or an action from the policy network. global epsilon if (randf(0, 1) <= epsilon): action = random.randrange(1, nbActions+1) else: # Forward the current state through the network. q = sess.run(outputlayer, feeddict={X: currentState}) # Find the max index (the chosen action). index = q.argmax() action = index + 1 # Decay the epsilon by multiplying by 0.999, not allowing it to go below a certain threshold. if (epsilon > epsilonMinimumValue): epsilon = epsilon * 0.999 nextState, reward, gameOver, stateInfo = env.act(action) if (reward == 1): winCount = winCount + 1 memory.remember(currentState, action, reward, nextState, gameOver) # Update the current state and if the game is over. currentState = nextState isGameOver = gameOver # We get a batch of training data to train the model. inputs, targets = memory.getBatch(output_layer, batchSize, nbActions, nbStates, sess, X) # Train the network which returns the error. , loss = sess.run([optimizer, cost], feeddict={X: inputs, Y: targets}) err = err + loss print("Epoch " + str(i) + ": err = " + str(err) + ": Win count = " + str(winCount) + " Win ratio = " + str(float(winCount)/float(i+1)*100)) # Save the variables to disk. save_path = saver.save(sess, os.getcwd()+"/model.ckpt") print("Model saved in file: %s" % save_path)if name == 'main': tf.app.run()""" TensorFlow translation of the torch example found here (written by SeanNaren). https://github.com/SeanNaren/TorchQLearningExample Original keras example found here (written by Eder Santana). https://gist.github.com/EderSantana/c7222daa328f0e885093#file-qlearn-py-L164 The agent plays a game of catch. Fruits drop from the sky and the agent can choose the actions left/stay/right to catch the fruit before it reaches the ground."""import tensorflow.compat.v1 as tftf.disablev2behavior()import numpy as npimport randomimport mathimport os# Parametersepsilon = 1 # The probability of choosing a random action (in training). This decays as iterations increase. (0 to 1)epsilonMinimumValue = 0.001 # The minimum value we want epsilon to reach in training. (0 to 1)nbActions = 3 # The number of actions. Since we only have left/stay/right that means 3 actions.epoch = 1001 # The number of games we want the system to run for.hiddenSize = 100 # Number of neurons in the hidden layers.maxMemory = 500 # How large should the memory be (where it stores its past experiences).batchSize = 50 # The mini-batch size for training. Samples are randomly taken from memory till mini-batch size.gridSize = 10 # The size of the grid that the agent is going to play the game on.nbStates = gridSize * gridSize # We eventually flatten to a 1d tensor to feed the network.discount = 0.9 # The discount is used to force the network to choose states that lead to the reward quicker (0 to 1) learningRate = 0.2 # Learning Rate for Stochastic Gradient Descent (our optimizer).# Create the base model.X = tf.placeholder(tf.float32, [None, nbStates])W1 = tf.Variable(tf.truncated_normal([nbStates, hiddenSize], stddev=1.0 / math.sqrt(float(nbStates))))b1 = tf.Variable(tf.truncated_normal([hiddenSize], stddev=0.01)) input_layer = tf.nn.relu(tf.matmul(X, W1) + b1)W2 = tf.Variable(tf.truncated_normal([hiddenSize, hiddenSize],stddev=1.0 / math.sqrt(float(hiddenSize))))b2 = tf.Variable(tf.truncated_normal([hiddenSize], stddev=0.01))hiddenlayer = tf.nn.relu(tf.matmul(inputlayer, W2) + b2)W3 = tf.Variable(tf.truncated_normal([hiddenSize, nbActions],stddev=1.0 / math.sqrt(float(hiddenSize))))b3 = tf.Variable(tf.truncated_normal([nbActions], stddev=0.01))outputlayer = tf.matmul(hiddenlayer, W3) + b3# True labelsY = tf.placeholder(tf.float32, [None, nbActions])# Mean squared error cost functioncost = tf.reducesum(tf.square(Y-outputlayer)) / (2*batchSize)# Stochastic Gradient Decent Optimizeroptimizer = tf.train.GradientDescentOptimizer(learningRate).minimize(cost)# Helper function: Chooses a random value between the two boundaries.def randf(s, e): return (float(random.randrange(0, (e - s) * 9999)) / 10000) + s;# The environment: Handles interactions and contains the state of the environmentclass CatchEnvironment(): def init(self, gridSize): self.gridSize = gridSize self.nbStates = self.gridSize * self.gridSize self.state = np.empty(3, dtype = np.uint8) # Returns the state of the environment. def observe(self): canvas = self.drawState() canvas = np.reshape(canvas, (-1,self.nbStates)) return canvas def drawState(self): canvas = np.zeros((self.gridSize, self.gridSize)) canvas[self.state[0]-1, self.state[1]-1] = 1 # Draw the fruit. # Draw the basket. The basket takes the adjacent two places to the position of basket. canvas[self.gridSize-1, self.state[2] -1 - 1] = 1 canvas[self.gridSize-1, self.state[2] -1] = 1 canvas[self.gridSize-1, self.state[2] -1 + 1] = 1 return canvas # Resets the environment. Randomly initialise the fruit position (always at the top to begin with) and bucket. def reset(self): initialFruitColumn = random.randrange(1, self.gridSize + 1) initialBucketPosition = random.randrange(2, self.gridSize + 1 - 1) self.state = np.array([1, initialFruitColumn, initialBucketPosition]) return self.getState() def getState(self): stateInfo = self.state fruit_row = stateInfo[0] fruit_col = stateInfo[1] basket = stateInfo[2] return fruitrow, fruitcol, basket # Returns the award that the agent has gained for being in the current environment state. def getReward(self): fruitRow, fruitColumn, basket = self.getState() if (fruitRow == self.gridSize - 1): # If the fruit has reached the bottom. if (abs(fruitColumn - basket) <= 1): # Check if the basket caught the fruit. return 1 else: return -1 else: return 0 def isGameOver(self): if (self.state[0] == self.gridSize - 1): return True else: return False def updateState(self, action): if (action == 1): action = -1 elif (action == 2): action = 0 else: action = 1 fruitRow, fruitColumn, basket = self.getState() newBasket = min(max(2, basket + action), self.gridSize - 1) # The min/max prevents the basket from moving out of the grid. fruitRow = fruitRow + 1 # The fruit is falling by 1 every action. self.state = np.array([fruitRow, fruitColumn, newBasket]) #Action can be 1 (move left) or 2 (move right) def act(self, action): self.updateState(action) reward = self.getReward() gameOver = self.isGameOver() return self.observe(), reward, gameOver, self.getState() # For purpose of the visual, I also return the state.# The memory: Handles the internal memory that we add experiences that occur based on agent's actions,# and creates batches of experiences based on the mini-batch size for training.class ReplayMemory: def init(self, gridSize, maxMemory, discount): self.maxMemory = maxMemory self.gridSize = gridSize self.nbStates = self.gridSize * self.gridSize self.discount = discount canvas = np.zeros((self.gridSize, self.gridSize)) canvas = np.reshape(canvas, (-1,self.nbStates)) self.inputState = np.empty((self.maxMemory, 100), dtype = np.float32) self.actions = np.zeros(self.maxMemory, dtype = np.uint8) self.nextState = np.empty((self.maxMemory, 100), dtype = np.float32) self.gameOver = np.empty(self.maxMemory, dtype = np.bool) self.rewards = np.empty(self.maxMemory, dtype = np.int8) self.count = 0 self.current = 0 # Appends the experience to the memory. def remember(self, currentState, action, reward, nextState, gameOver): self.actions[self.current] = action self.rewards[self.current] = reward self.inputState[self.current, ...] = currentState self.nextState[self.current, ...] = nextState self.gameOver[self.current] = gameOver self.count = max(self.count, self.current + 1) self.current = (self.current + 1) % self.maxMemory def getBatch(self, model, batchSize, nbActions, nbStates, sess, X): # We check to see if we have enough memory inputs to make an entire batch, if not we create the biggest # batch we can (at the beginning of training we will not have enough experience to fill a batch). memoryLength = self.count chosenBatchSize = min(batchSize, memoryLength) inputs = np.zeros((chosenBatchSize, nbStates)) targets = np.zeros((chosenBatchSize, nbActions)) # Fill the inputs and targets up. for i in xrange(chosenBatchSize): if memoryLength == 1: memoryLength = 2 # Choose a random memory experience to add to the batch. randomIndex = random.randrange(1, memoryLength) current_inputState = np.reshape(self.inputState[randomIndex], (1, 100)) target = sess.run(model, feeddict={X: currentinputState}) current_nextState = np.reshape(self.nextState[randomIndex], (1, 100)) currentoutputs = sess.run(model, feeddict={X: current_nextState}) # Gives us Q_sa, the max q for the next state. nextStateMaxQ = np.amax(current_outputs) if (self.gameOver[randomIndex] == True): target[0, [self.actions[randomIndex]-1]] = self.rewards[randomIndex] else: # reward + discount(gamma) * max_a' Q(s',a') # We are setting the Q-value for the action to r + gamma*max a' Q(s', a'). The rest stay the same # to give an error of 0 for those outputs. target[0, [self.actions[randomIndex]-1]] = self.rewards[randomIndex] + self.discount * nextStateMaxQ # Update the inputs and targets. inputs[i] = current_inputState targets[i] = target return inputs, targets def main(_): print("Training new model") # Define Environment env = CatchEnvironment(gridSize) # Define Replay Memory memory = ReplayMemory(gridSize, maxMemory, discount) # Add ops to save and restore all the variables. saver = tf.train.Saver() winCount = 0 with tf.Session() as sess: tf.initializeallvariables().run() for i in xrange(epoch): # Initialize the environment. err = 0 env.reset() isGameOver = False # The initial state of the environment. currentState = env.observe() while (isGameOver != True): action = -9999 # action initilization # Decides if we should choose a random action, or an action from the policy network. global epsilon if (randf(0, 1) <= epsilon): action = random.randrange(1, nbActions+1) else: # Forward the current state through the network. q = sess.run(outputlayer, feeddict={X: currentState}) # Find the max index (the chosen action). index = q.argmax() action = index + 1 # Decay the epsilon by multiplying by 0.999, not allowing it to go below a certain threshold. if (epsilon > epsilonMinimumValue): epsilon = epsilon * 0.999 nextState, reward, gameOver, stateInfo = env.act(action) if (reward == 1): winCount = winCount + 1 memory.remember(currentState, action, reward, nextState, gameOver) # Update the current state and if the game is over. currentState = nextState isGameOver = gameOver # We get a batch of training data to train the model. inputs, targets = memory.getBatch(output_layer, batchSize, nbActions, nbStates, sess, X) # Train the network which returns the error이. , loss = sess.run([optimizer, cost], feeddict={X: inputs, Y: targets}) err = err + loss print("Epoch " + str(i) + ": err = " + str(err) + ": Win count = " + str(winCount) + " Win ratio = " + str(float(winCount)/float(i+1)*100)) # Save the variables to disk. save_path = saver.save(sess, os.getcwd()+"/model.ckpt") print("Model saved in file: %s" % save_path)if name == 'main': tf.app.run() 입니다그런데 이런 오류가 생겼습니다WARNING:tensorflow:From C:\ProgramData\Anaconda3\envs\tens2\lib\site-packages\tensorflowcore\python\compat\v2compat.py:65: disableresourcevariables (from tensorflow.python.ops.variablescope) is deprecated and will be removed in a future version.Instructions for updating:non-resource variables are not supported in the long termTraining new modelWARNING:tensorflow:From C:\ProgramData\Anaconda3\envs\tens2\lib\site-packages\tensorflowcore\python\util\tfshoulduse.py:198: initializeallvariables (from tensorflow.python.ops.variables) is deprecated and will be removed after 2017-03-02.Instructions for updating:Use tf.globalvariablesinitializer instead.W0820 22:17:13.656675 9068 deprecation.py:323] From C:\ProgramData\Anaconda3\envs\tens2\lib\site-packages\tensorflowcore\python\util\tfshoulduse.py:198: initializeallvariables (from tensorflow.python.ops.variables) is deprecated and will be removed after 2017-03-02.Instructions for updating:Use tf.globalvariablesinitializer instead.Traceback (most recent call last): File "C:\Windows\system32\python", line 267, in <module> tf.app.run() File "C:\ProgramData\Anaconda3\envs\tens2\lib\site-packages\tensorflowcore\python\platform\app.py", line 40, in run run(main=main, argv=argv, flagsparser=parseflagstolerateundef) File "C:\ProgramData\Anaconda3\envs\tens_2\lib\site-packages\absl\app.py", line 299, in run runmain(main, args) File "C:\ProgramData\Anaconda3\envs\tens2\lib\site-packages\absl\app.py", line 250, in run_main sys.exit(main(argv)) File "C:\Windows\system32\python", line 216, in main for i in xrange(epoch):NameError: name 'xrange' is not defined어떻게 해결해야 할까요?매우 길지만 해결해 주시면 감사하겠습니다 ㅠㅠ
- 기타 고민상담고민상담Q. INTP 성격의 단점을 보완하는 방법전 INTP 학생입니다. 근데 제 생활이 딱히 만족스럽지가 않아서 자존감이 자꾸 떨어집니다. I 성향이 상당히 커서 친하지 않은 사람 앞에만 서면 완전 극도로 소심해지고요, 이런 모습이 진짜 너무 답답해요. 그리고 낄 때 끼고 빠질 때 빠지는걸 잘 못하고 선을 자꾸 넘기도 해요. 그리고 저도 모르게 무례하게 행동하는 경우도 많아서 후회하는 일이 많습니다. 또 제가 관심있는 분야에는 제가 진짜 전문가처럼 파고드는데 막상 중요한 이 학업에서 제가 흥미를 느끼지 못하는 과목은 점수가 좋지 않으니 이런 것도 걱정이 됩니다. 제 부족한 부분을 채워나가고 싶으나 항상 실수를 저지른 후에 깨달으니 문제입니다. 도대체 어떻게 해야할까요?
- 생활꿀팁생활Q. java 자바 for문 중 배열length관련 질문for(int i=0; i<5; i++) {int sum += intArray[i].length;if(i==4) {System.out.print(sum + "개의 정수를 입력하시오>>");}}위와같은 for문을 작성중인데 두번째줄 sum선언에서 오류가 생깁니다.int intArray[][] = new int[5][];intArray[0] = new int[4];intArray[1] = new int[1];intArray[2] = new int[2];intArray[3] = new int[3];intArray배열은 위처럼 비정방형 배열로 선언해놓은 상태입니다.scanner를 사용해 각 배열의 값을 입력받으려고 하는데요"'총 배열의 개수'를 입력하시오 "라고 출력을 하고싶습니다총 배열의 개수를 구하는 방법으로 저는 위와같이 for문을 사용해서 구하고 싶었습니다.제가 묻고싶은 곳은 int sum += intArray[i].length; 부분의 '+='부분에서 Syntax Error가 발생한다는겁니다다른 곳에서는 잘만 되던 +=가 저 for문에서만 에러가 발생합니다int sum = sum + intArray[i].length; 로 바꾸어도 두번째sum에서 초기화가 되지 않았다고 오류가발생합니다.원인이 무엇일까요? 도와주세요 ㅠㅠ
- 생활꿀팁생활Q. 파이썬 크롤링에서의 for 관련 질문드립니다.import urllib.requestimport urllib.parsefrom bs4 import BeautifulSoupimport osimport requestsfrom selenium import webdriverimport csvdriver = webdriver.Chrome('C:/rrr/chromedriver.exe')baseurl = 'https://www.sbs.co.kr/schedule/index.html?type=dmb&channel=DMB+TV&pmDate='plusurl = input("날짜입력(ex:20200815):")url = baseurl + urllib.parse.quote_plus(plusurl) driver.get(url)html = driver.page_sourcesoup = BeautifulSoup(html)#--------------select일경우------------------try: for i in range(50): time1 = soup.select('.spthours')[i].text time2 = soup.select('.spthours')[i+1].text title1 = soup.select('.spititle')[i].text print(time1, time2, title1, '-1,-1', sep=',') i = i + 1except: title1 = soup.select('.spititle')[i].text print(time2, title1, '-1,-1', sep=',')--------------------------------------------------------------------------------------------------이전에 이어서 질문드립니다.답변달아주신 분들 덕분에 +3지식과 문제가 해결되에 뒤에 주르륵 만들어보았습니다.위의 코드를 돌려서 바로 csv파일을 만들 계획이긴 한데,요지는 for i in range(50): 부분입니다.크롤링할때 매일 시간,편성부분이 매번 달라지는데, 'in soup : '로 썼다간 에러가 뜨더군요...ㅠ그래서 넉넉하게 범위 50으로 적긴했는데, in 뒤에 적절하게 들어갈만한 변수가 있을까요??