# Julia - Method Error

**URL:** https://discourse.julialang.org/t/julia-method-error/39804
**Category:** Internals & Design
**Tags:** question
**Created:** [May 20, 2020, 6:51am UTC](https://discourse.julialang.org/t/julia-method-error/39804 "2020-05-20T06:51:19Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Dishant-P](https://avatars.discourse-cdn.com/v4/letter/d/3d9bf3/32.png) [@Dishant-P](https://discourse.julialang.org/u/Dishant-P)
#### Post date: [May 20, 2020, 6:51am UTC](https://discourse.julialang.org/t/julia-method-error/39804/1 "2020-05-20T06:51:19Z")

</div>

Even though I defined the method, the method is still not recognised.  
Following are the two functions defined.

```julia
@resumable function iterate_regions(self::Conv13, image)
    h, w = size(image)
    
    for i in 1:h-1
        for j in 1:w-1
            im_region = image[i:(i+3), j:(j+3)]
            @yield im_region, i , j
        end
    end
end

function forward(self::Conv13, input)
    self.last_input = input
    
    h, w = size(input)
    output = zeros(Float64, (h - 2, w - 2, self.num_filters))
    
    for (im_region, i, j) in iterate_regions(self, input)
        output[i, j] = sum(im_region * self.filters, dims=(1,2))
    end
    
    return output
end

```

Now when I call the forward, just for checking the function, by giving it the struct instance as well as a 2-D array, it gives an unusual error.  
`forward(Conv::Conv3x3, convert(Array{Float64},train_images[:,:,1]))`

MethodError: no method matching \*(::Array{Float64,2}, ::Array{Float64,3})  
Closest candidates are:  
\*(::Any, ::Any, !Matched::Any, !Matched::Any…) at operators.jl:529  
\*(!Matched::PyObject, ::Any) at C:\Users\dishant.julia\packages\PyCall\zqDXB\src\pyoperators.jl:13  
\*(::Union{DenseArray{T,2}, Base.ReinterpretArray{T,2,S,A} where S where A\<:Union{SubArray{T,N,A,I,true} where I\<:Union{Tuple{Vararg{Real,N} where N}, Tuple{AbstractUnitRange,Vararg{Any,N} where N}} where A\<:DenseArray where N where T, DenseArray}, Base.ReshapedArray{T,2,A,MI} where MI\<:Tuple{Vararg{Base.MultiplicativeInverses…  
.  
.  
.  
Stacktrace:  
[1] forward(::Conv3x3, ::Array{Float64,2}) at .\In[16]:9  
[2] top-level scope at In[26]:3

And even the stack trace shows that the values passed are correct. I don’t know why it is not able to find forward.

---

<div class="post-metadata">

### Author: ![mcabbott](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mcabbott/32/6603_2.png) [@mcabbott](https://discourse.julialang.org/u/mcabbott)
#### Post date: [May 20, 2020, 9:39am UTC](https://discourse.julialang.org/t/julia-method-error/39804/2 "2020-05-20T09:39:00Z")

</div>

> [@Dishant-P](#):
>
> MethodError: no method matching \*(::Array{Float64,2}, ::Array{Float64,3})

This is the problem, `*` doesn’t work on 3-arrays.

```julia
ones(2,2) * ones(2) # matrix * vector is ok
ones(2,2) * ones(2,2) # matrix * matrix is ok
ones(2,2) * ones(2,2,2) # MethodError

```

I’m not too sure what you are doing, but you may have wanted element-wise `.*` here? Or if you do want matrix multiplication, then you could `reshape` the second one.

---

<div class="post-metadata">

### Author: ![Dishant-P](https://avatars.discourse-cdn.com/v4/letter/d/3d9bf3/32.png) [@Dishant-P](https://discourse.julialang.org/u/Dishant-P)
#### Post date: [May 20, 2020, 10:08am UTC](https://discourse.julialang.org/t/julia-method-error/39804/3 "2020-05-20T10:08:14Z")

</div>

Hey, that’s exactly what I was trying for. An element wise multiplication and I didn’t notice that the problem was in the internal definition rather than the function itself.  
Thank you so much. It works now with .\*  
😄
