Comments (10)
I ve got the same....
from numpycnn.
Thanks but still an issue
Working with conv layer 1*
('Filter ', 1)
Traceback (most recent call last):
File "example.py", line 44, in
l1_feature_map = numpycnn.conv(img, l1_filter)
File "/Users/lomenie/Documents/GitHub/NumPyCNN/numpycnn.py", line 78, in conv
conv_map = conv_(img, curr_filter)
File "/Users/lomenie/Documents/GitHub/NumPyCNN/numpycnn.py", line 38, in conv_
curr_result = curr_region * conv_filter
ValueError: operands could not be broadcast together with shapes (2,2) (3,3)
from numpycnn.
no answer from the developer ?
from numpycnn.
Thanks for your note.
The shared code is running fine with me and some other people. This is why I got confused of it.
But after investigating the code well, I figured out the source the error and I am planning to work on the code and solve it in the next few days.
Thanks again.
from numpycnn.
The issue is fixed. The issue was due to incompatibility of shape between the filter and the image region being worked on. It is solved based on such lines:
curr_region = img[r-numpy.uint16(numpy.floor(filter_size/2)):r+numpy.uint16(numpy.ceil(filter_size/2)),
c-numpy.uint16(numpy.floor(filter_size/2)):c+numpy.uint16(numpy.ceil(filter_size/2))]
from numpycnn.
from numpycnn.
Yes this is the reason.
The code is running in my PC without error. The same code gives an error on another without changing any part.
At all, the version of Python and NumPy I used are as follows:
The project is tested using Python 3.5.2 installed inside Anaconda 4.2.0 (64-bit)
NumPy version used is 1.14.0
from numpycnn.
With the first code here is the pb (so I do not think it is a uint type issue)
Working with conv layer 1
('Filter ', 1)
Filter Size
3
('Filter ', 2)
Filter Size
3
ReLU
Pooling
End of conv layer 1
Working with conv layer 2
('Filter ', 1)
Filter Size
5
Filter Size
5
('Filter ', 2)
Filter Size
5
Filter Size
5
('Filter ', 3)
Filter Size
5
Filter Size
5
ReLU
Pooling
End of conv layer 2
Working with conv layer 3
('Filter ', 1)
Filter Size
7
Traceback (most recent call last):
File "NumPyCNN.py", line 129, in
l3_feature_map = conv(l2_feature_map_relu_pool, l3_filter)
File "NumPyCNN.py", line 58, in conv
conv_map = conv_(img[:, :, 0], curr_filter[:, :, 0]) # Array holding the sum of all feature maps.
File "NumPyCNN.py", line 23, in conv_
curr_result = curr_region * conv_filter
ValueError: operands could not be broadcast together with shapes (7,6) (7,7)
from numpycnn.
I am very thankful for your notes.
You are right. The bug still exist.
I figured a fault that may causing such error after running such code on another device with another version of NumPy.
I figured out that the numpy.ceil was not working correctly. When I run this line,
numpy.uint16(numpy.ceil(3/2))
The expected output is 2 but it returns 1. Due to dividing two integers (3 and 2), the result will also be an integer (1). The ceil of that integer is 1.
Based on that, the region size is calculated based on the following code will be always smaller than the filter size:
curr_region = img[r-numpy.uint16(numpy.floor(filter_size/2)):r+numpy.uint16(numpy.ceil(filter_size/2)),
c-numpy.uint16(numpy.floor(filter_size/2)):c+numpy.uint16(numpy.ceil(filter_size/2))]
This bug is fixed by making one of the two numbers float. For example, numpy.ceil(filter_size/2.0). The previous code will be as follows:
curr_region = img[r-numpy.uint16(numpy.floor(filter_size/2.0)):r+numpy.uint16(numpy.ceil(filter_size/2.0)), c-numpy.uint16(numpy.floor(filter_size/2.0)):c+numpy.uint16(numpy.ceil(filter_size/2.0))]
from numpycnn.
The issue is closed for being solved.
from numpycnn.
Related Issues (10)
- how to create my own dataset? HOT 1
- sigmoid(sop) function not numerically safe HOT 1
- size of pool_out HOT 2
- A code error in relu function HOT 1
- some bugs to fix in pooling() and relu() HOT 3
- A code error in pooling function HOT 2
- pooling error when featuremap.shape[0] or featuremap.shape[1] is odd,, the pooling result is not same with caffe's pooling layer
- Conv function error condition HOT 1
- 小白学习CNN的问题 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from numpycnn.