# LSTM for sequences of geometric shapes

Hi guys, could you please shed light on the following?

Requirement:

1. Create a sequence predictor based on geometric shapes
2. Shapes can be circles, rectangles and triangles
3. Such shapes can vary in size and angles if they have
4. The sequencer should try to predict the most likely next shape and its size.

What has been tried:

Basics:

• The data has been normalized
• Training data, validation data and test data are separate and different sets

Implementation:

• Passed the shape’s numeric data as part of the sequence e.g. the points that represent the triangle, it seems the LSTM is trying to do some math with it and it never picks a pattern, I guess, given the different shapes
• Make the shape’s point strings and use a categorical LSTM: the strings are so varied that no pattern is picked
• Round the numbers of the dimensions and make them string: too much precision gets lost and I get a crazy big dictionary , no pattern is picked

In all cases the Test data evaluation is no more than 40% accurate

Any ideas to tackle this type of requirement?

Thanks!

1 Like

Hello George,

I’m not sure how much this will help, but here are a few things I might think about too. And these might be things you’re already thinking about too!

First is to be careful with how the data is normalized, think about the domain and range of your inputs and outputs. If all of your circles have a max radius of 10, it might be hard for your model to predict a number larger than that.

Second is maybe you can describe the shapes differently than points. I’m not sure exactly what your data looks like, but coordinates I think might not be important. Without putting the shapes on a coordinate system, you could define any rectangle for example with just a height and width, any circle could be defined with just a radius, and I think a triangle could be defined with two side lengths and the angle between them. You could use these simpler representations as inputs and outputs, and maybe they would be easier for the model to pick up.

Third is maybe try breaking up the problem a bit, like first predicting what type of shape comes next, then predicting the dimensions and size of that shape.

I hope this helps a bit!

2 Likes

Thanks asweet

I am trying now with lengths and angels, and it doesn’t work either

I seems to me that LSTM tries to make sense of any number as a function of something, but in this case the sequence of shapes and sizes sequences are arbitrary so there is no function to find

On the other hand, when treating it as categorical the sizes create too much variation for categories. I think I don’t understand how to use the LSTM for this case where there is mix of categorical-numerical sequences.

In my case there is no logic on the sequence, but common sequences that need to be memorized and identified once the pattern is forming as one of the ‘known’ sequences

1 Like