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

File dependencies #244

Closed
rpantera opened this issue May 20, 2019 · 7 comments
Closed

File dependencies #244

rpantera opened this issue May 20, 2019 · 7 comments
Assignees

Comments

@rpantera
Copy link

Jupyter Notebook
Untitled3
Last Checkpoint: 04/16/2018
(autosaved)
Current Kernel Logo
Logout
Python 3 Trusted
File
Edit
View
Insert
Cell
Kernel
Widgets
Help
Run
In [1]:

1
%matplotlib tk
2
import matplotlib.pyplot as plt
3
from sklearn import datasets
4
from neupy import algorithms, utils
5

6
from helpers import plot_2d_grid
7

8

9
plt.style.use('ggplot')
10
utils.reproducible()
11

12

13
if name == 'main':
14
GRID_WIDTH = 20
15
GRID_HEIGHT = 1
16

17
data, targets = datasets.make_moons(n_samples=400, noise=0.1)
18
data = data[targets == 1]
19

20
sofm = algorithms.SOFM(
21
n_inputs=2,
22
features_grid=(GRID_HEIGHT, GRID_WIDTH),
23

24
verbose=True,
25
shuffle_data=True,
26

27
# The winning neuron will be selected based on the
28
# Euclidean distance. For this task it's important
29
# that distance is Euclidean. Other distances will
30
# not give us the same results.
31
distance='euclid',
32

33
learning_radius=2,
34
# Reduce learning radius by 1 after every 20 epochs.
35
# Learning radius will be equal to 2 during first
36
# 20 epochs and on the 21st epoch it will be equal to 1.
37
reduce_radius_after=20,
38

39
# 2 Means that neighbour neurons will have high learning
40
# rates during the first iterations
41
std=2,
42
# Defines a rate at which parameter std will be reduced.
43
# Reduction is monotonic and reduces after each epoch.
44
# In 50 epochs std = 2 / 2 = 1 and after 100 epochs
45
# std = 2 / 3 and so on.
46
reduce_std_after=50,
47

48
# Step (or learning rate)
49
step=0.3,
50
# Defines a rate at which parameter step will reduced.
51
# Reduction is monotonic and reduces after each epoch.
52
# In 50 epochs step = 0.3 / 2 = 0.15 and after 100 epochs
53
# std = 0.3 / 3 = 0.1 and so on.
54
reduce_step_after=50,
55
)
56
sofm.train(data, epochs=20)
57

58
red, blue = ('#E24A33', '#348ABD')
59

60
plt.scatter(*data.T, color=blue)
61
plt.scatter(*sofm.weight, color=red)
62

63
weights = sofm.weight.reshape((2, GRID_HEIGHT, GRID_WIDTH))
64
plot_2d_grid(weights, color=red)
65

66
plt.show()
67

ModuleNotFoundError Traceback (most recent call last)
in
4 from neupy import algorithms, utils
5
----> 6 from helpers import plot_2d_grid
7
8

ModuleNotFoundError: No module named 'helpers'

I did not move any files from where the examples were installed. I did not find a "helpers" file related to neupy on my disk. I read all the fixes for that type of problem. After 4 hours I could not make this file work.

@rpantera
Copy link
Author

This will not work in a Jupiter notebook. Just got it to work in MAC OSX terminal

@rpantera
Copy link
Author

Is there any way to make this Neupy work with Jupiter notebooks or spyder in Anaconda?

@rpantera
Copy link
Author

Jupyter. Autocorrect keeps on fixing it.

@itdxer
Copy link
Owner

itdxer commented May 20, 2019

You can find this function here: https://github.com/itdxer/neupy/blob/master/examples/competitive/utils.py

@itdxer
Copy link
Owner

itdxer commented May 20, 2019

It should have been utils instead of helpers. I've fixes 3 examples that still used old helpers module

@itdxer itdxer self-assigned this May 20, 2019
@rpantera
Copy link
Author

rpantera commented May 20, 2019 via email

@itdxer
Copy link
Owner

itdxer commented May 20, 2019

No, I'm not. Sorry, I don't have a lot of free time

@itdxer itdxer closed this as completed May 20, 2019
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

No branches or pull requests

2 participants