Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 7f0e442

Browse files
循环的最后一个元素和下一次循环的第一个元素时间不连续
steps = np.linspace(start, end, TIME_STEP, dtype=np.float32) 其中默认参数endpoint=True,也就是说这一次循环的最后一个元素和下一次循环的第一个元素是一致的,按照RNN传递的state的特点,应该保证输入是关于时间连续的,所以不应该有相邻的时间是一致的情况,这可能不是想要的,所以我认为这里是一个小bug。
1 parent 51c6c66 commit 7f0e442

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎tutorial-contents/403_RNN_regressor.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def forward(self, x, h_state):
7777
for step in range(100):
7878
start, end = step * np.pi, (step+1)*np.pi # time range
7979
# use sin predicts cos
80-
steps = np.linspace(start, end, TIME_STEP, dtype=np.float32) # float32 for converting torch FloatTensor
80+
steps = np.linspace(start, end, TIME_STEP, dtype=np.float32, endpoint=False) # float32 for converting torch FloatTensor
8181
x_np = np.sin(steps)
8282
y_np = np.cos(steps)
8383

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /