Python with turtle, move turtle from one spot to another
It's a really simple question, though I didn't find a solution. I want that when the turtle reaches a certain position, I use a command to move it to another position. The command I use is:
while turtle.xcor() and turtle.ycor() == **: turtle.goto()
But it seems it doesn't work...
1 answer

I want that when the turtle reaches a certain position, I use a command to move it to another position.
The turtle walks a floating point plane so doing exact (integer) position comparisons is problematic. Instead, calculate the distance between the turtle and its target. If that distance is less than some small value (say the radius of the turtle cursor) consider it having hit the target and then take action:
if turtle.distance(25, 50) < 5: # turtle is upon the target turtle.goto(100, 100)
See also questions close to this topic

Tied weights in tensorflow recurrent cell
In the context of an fullyconnected autoencoder this paper states that one type of regularization is to use tied weights for weight matrixes (section 2in the paper). In the paper the weight matrix for the decoder is the transposed of the encoding matrix of the encoder. A pseudopython writing of this in tensorflow can be:
import tensorflow as tf encoder_activation = tf.add(tf.matmul(input_data, W_encoder),self.b_encoder) encoder = tf.tanh(activation) decoder_activation = tf.add(tf.matmul(encoder, tf.transpose(W_encoder)),self.b_decoder) decoder = tf.tanh(decoder_activation)
Where input_data is a placeholder and b_* and W_encoder are the biases and tied weight matrix of the encoder. Shapes are given so that no dimensionality problems arises.
My question would be how would I use tiedweight matrix on a Tensorflow recurrent cell ? If possible a pseudo python/code hint of the main idea is verry appreciated. I'm not too familiar with the inner workings of the rnn cell. Consider the most basic cell that make illustration of this more easy
Thankyou 
Imitate the copy function of Excel or Libre Office with openpyxl and python3 (copy with properties to new position)
is there a way to imitate the copy function of "Excel" or "LibreOffice Calc" using openpyxl and python3?
I would like to specify a certain range (e.g. "A1:E5") and copy the "border", "alignment", "number_format", "value", "merged_cells", ... properties of each cell to an other position (and probably to another worksheet), whereby the used formulas should be updated automatically to the new position. The new formulas are intended to refer to cells within the target worksheet and not to the old cells in the original worksheet.
My project:
I generate a workbook for every month. This workbook contains yield monitoring tables that list all working days. Although the tables differ from month to month, all have the same structure within a workbook, so I would like to create a template and paste it into the individual worksheets.
Copying the entire worksheet is not really a solution because I also want to specify the position of the table in the target worksheet.
My current code (where the formulas are not automatically updated):
import copy # The tuple "topLeftCell" represents the assumed new position in the target worksheet. It is zerobased. (e.g. (0,0) or (7,3)) # "templateSheet" is the template from which to copy. # "worksheet" is the target worksheet # Create the same "merged_cells" as in the template at the new positioin for cell_range in templateSheet.merged_cells.ranges: startCol, startRow, endCol, endRow = cell_range.bounds worksheet.merge_cells(start_column=topLeftCell[0] + startCol, start_row=topLeftCell[1] + startRow, end_column=topLeftCell[0] + endCol, end_row=topLeftCell[1] + endRow) colNumber = topLeftCell[0] + 1 # 1 is added up because topLeftCell is zero based. rowNumber = topLeftCell[1] + 1 # 1 is added up because topLeftcell is zero based. # Copy the properties of the old cells into the target worksheet for row in templateSheet[templateSheet.dimensions]: tmpCol = colNumber # sets the column back to the original value for cell in row: ws_cell = worksheet.cell(column=tmpCol, row=rowNumber) ws_cell.alignment = copy.copy(cell.alignment) ws_cell.border = copy.copy(cell.border) ws_cell.font = copy.copy(cell.font) ws_cell.number_format = copy.copy(cell.number_format) ws_cell.value = cell.value tmpCol += 1 # move one column further rowNumber += 1 # moves to the next line
Since copying ranges is actually a common task, I assumed that openpyxl provides a function or method for doing so. Unfortunately, I could not find one so far.
I'm using openpyxl version 2.5.1 (and Python 3.5.2).
Best regards AFoeee

sigmoid + binary_crossentropy and flow_from_directory
If we want to use sigmoid + binary_crossentropy for multilabel classification (like each image can have multi labels) in Keras, we need to write custom batch generator,
flow_from_directory
[1] can't be used? 
Attempting to bounce off window wall with Turtle
The program works but when it hits a wall the turtle undo's the last step and tries again. However, it keeps inputting the same forward distance and angle causing it to move in the same path in a loop. Is there a way to stop the turtle from taking the same value again?
from turtle import Turtle, Screen import random def createTurtle(color, width): tempName = Turtle("arrow") tempName.speed("fastest") tempName.color(color) tempName.width(width) return tempName def inScreen(screen, turt): x = screen.window_width() / 2 y = screen.window_height() / 2 turtleX, turtleY = turt.pos() if not (x < turtleX < x) and (y < turtleY < y): return False return True def moveTurtle(screen, turt): while True: while inScreen(screen, turt): turt.fd(random.randrange(100)) turt.left(random.randrange(360)) if (inScreen(screen, turt) == False): turt.undo() continue wn = Screen() alpha = createTurtle("red", 3) moveTurtle(wn, alpha) wn.exitonclick()

Random Turtle movement, bounce off wall
Created the program to randomize the movement of the turtle but cannot get it to bounce off the window/canvas limits. Tried a few solutions posted with similar questions but still no luck.
from turtle import Turtle, Screen import random def createTurtle(color, width): tempName = Turtle("arrow") tempName.speed("fastest") tempName.color(color) tempName.width(width) return tempName def inScreen(screen, turt): x = screen.window_height() / 2 y = screen.window_height() / 2 min_x, max_x = x, x min_y, max_y = y, y turtleX, turtleY = turt.pos() while (min_x <= turtleX <= max_x) and (min_y <= turtleY <= max_y): turt.left(random.randrange(360)) turt.fd(random.randrange(50)) turtleX, turtleY = turt.pos() print(turtleX, ",", turtleY) wn = Screen() alpha = createTurtle("red", 3) inScreen(wn, alpha) wn.exitonclick()

Random Turtle movement, bound in window
Created the program to randomize the movement of the turtle but cannot get it to break the loop once it touches a boundary (window). Tried a few solutions posted with similar questions but still no luck.
from turtle import Turtle, Screen import random def createTurtle(color, width): tempName = Turtle("turtle") tempName.speed("fastest") tempName.color(color) tempName.width(width) return tempName def inScreen(screen, turt): min_x, max_x = wn.window_width() / 2 , wn.window_width() / 2 min_y, max_y = wn.window_height() / 2 , wn.window_height() / 2 turtleX, turtleY = turt.pos() while (min_x < turtleX < max_x) and (min_y < turtleY < max_y): turt.left(random.randrange(360)) turt.fd(random.randrange(100)) turtleX, turtleY = turt.pos() print(turtleX, ",", turtleY) wn = Screen() alpha = createTurtle("red", 3) inScreen(wn, alpha) wn.exitonclick()