Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix scalar random samplng #57

Merged

Conversation

Superjomn
Copy link
Contributor

  • changing form random sample to equidistant sampling

Copy link
Member

@jacquesqiao jacquesqiao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Superjomn Superjomn merged commit f01c3a8 into PaddlePaddle:develop Jan 4, 2018
end_idx = len(data) - 1
res = []
for i in xrange(num_records):
id = int(end_idx - i * span)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

id 是 python保留字,建议换一个

span = float(len(data) / num_records)
end_idx = len(data) - 1
res = []
for i in xrange(num_records):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里逻辑有点问题。取 n 个点的话, 应该除以 (n-1),比如 10个点取三个,应该是 10/2 = 5, 取 0, 5 , 9


span = float(len(data)) / (num_records-1)
span_multiply = 0

data_idx = int(span_multiply * span)
sampled_data = []

while data_idx < len(data):
    sampled_data.append(data[data_idx])
    span_multiply += 1
    data_idx = int(span_multiply * span)

sampled_data.append(data[-1])
return sampled_data

Copy link
Contributor Author

@Superjomn Superjomn Jan 4, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

现在是 10个点取3个的话:
9, 5, 0
reverse-> 0, 5, 9

这个应该没有问题 @daming-lu

jacquesqiao pushed a commit to jacquesqiao/VisualDL that referenced this pull request Jan 12, 2018
jacquesqiao pushed a commit to jacquesqiao/VisualDL that referenced this pull request Jan 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants