Keras.NET icon indicating copy to clipboard operation
Keras.NET copied to clipboard

Specify 'None' as Shape dimension

Open ordinaryorange opened this issue 1 year ago • 3 comments

I'm trying to do a Conv1D layer with variable features

1st attempt

let model = new Sequential()
model.Add(new Input(Shape(3)))
model.Add(new Conv1D(50, 1 ))

Error: Python.Runtime.PythonException: ValueError : Input 0 of layer "conv1d_9" is incompatible with the layer: expected min_ndim=3, found ndim=2. Full shape received: (None, 3)

2nd attempt setting the batch_shape arg (thinking the batch size will fix it)

let model = new Sequential()
model.Add(new Input(Shape(3), Shape(1)))
model.Add(new Conv1D(50, 1 ))

Error: Python.Runtime.PythonException: ValueError : Only provide the shape OR batch_input_shape argument to Input, not both at the same time.

According to this issue batch_size is being depreciated from tensorflow. So I figure that is the reason for the latter python error.

I've looked at the design of the Shape class and in it's current form and it only takes int types so dead end there.

The first error suggests that internally within Keras.NET a conversion is being done to emit (None,3) to python but in my brief look I cant see how.

Suggestions for a work around ? Or even a pointer to the section of code in Keras.NET that does the shape conversion, so I can hack in something local ?

ordinaryorange avatar Jul 12 '22 09:07 ordinaryorange

So I've discovered that the Shape class has already been updated in v3.8.6 to handle this. I was looking at the nuget source, which was 3.8.5 Can we get 3.8.6 pushed to nuget.org ?

ordinaryorange avatar Jul 12 '22 12:07 ordinaryorange

Ok sure I will plan to do this sometime this week

On Tue, Jul 12, 2022 at 9:45 PM ordinaryorange @.***> wrote:

So I've discovered that the Shape class has already been updated in v3.8.6 to handle this. I was looking at the nuget source, which was 3.8.5 Can we get 3.8.6 pushed to nuget.org ?

— Reply to this email directly, view it on GitHub https://github.com/SciSharp/Keras.NET/issues/231#issuecomment-1181686919, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABQJAKM52MLFDE5C7ZYUOBTVTVOV5ANCNFSM53KJGZLQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

-- Regards, Deepak

deepakkumar1984 avatar Jul 12 '22 12:07 deepakkumar1984

Compiled source locally here and referencing that pkg for the moment. At your leisure. Ta

ordinaryorange avatar Jul 12 '22 12:07 ordinaryorange

Stale issue message

github-actions[bot] avatar May 03 '23 00:05 github-actions[bot]