Shapes are: General Data Protection Regulation(GDPR) Guidelines BYJU’S

Posted on

python — Tensorflow ValueError Shapes are incompatible

Whatever I do, i can’t fix this ValueError from coming up: ValueError: Shapes (35, 1) and (700, 35) are incompatible
I’m new to tensorflow and am trying to build a «simple», maybe still somewhat big, neural network. I have tried changing the input_shape, loss function and numbers of neurons but with no success.

I’ve included what I think is the important portion of code, the rest is just fetching the data and formatting it.

model = tf.keras.Sequential([
    #tf.keras.layers.Flatten(input_shape=700,),
    tf.keras.layers.Dense(800, activation='sigmoid', input_shape=(700,)),
    tf.keras.layers.Dense(1000, activation='sigmoid'),
    tf.keras.layers.Dense(500, activation='sigmoid'),
    tf.keras.layers.Dense(150, activation='sigmoid'),
    tf.keras.layers.Dense(35)
])
model.compile(optimizer='adam',
              loss=tf.keras.losses.sparse_categorical_crossentropy,
              metrics=['accuracy'])
train_dataset = tf. data.Dataset.from_tensor_slices((arrayInput, arrayTarget))
for feat, targ in train_dataset.take(5):
  print('Features: {}, Target: {}'.format(feat, targ))
model.fit(train_dataset, epochs=EPOCHS)
model.save('savedmodel')

Output:

Features: [8.32999992e+00 8.18400002e+00 8.10999966e+00 8.05000019e+00
 ...SHORTENED BUT 700 LONG...
 1.13643000e+05 7.27480000e+04 1.00100000e+05 3.49750000e+04], Target: [8.72999954 8.75       8.64099979 8.60000038 8.64000034 8.66499996
 8.52999973 8.51000023 8.52000046 8.56000042 8.51000023 8.95499992
 8.85999966 8.75010014 8.74499989 8.75       8.76000023 8.77000046
 8.64500046 8.65200043 8.60429955 8.69999981 8.89000034 8.97999954
 8.92000008 9.21000004 9.38000011 9.47599983 9.57999992 9.46500015
 9.44999981 9.57999992 9.625      9.76000023 9.67000008]
Features: [8.18400002e+00 8.10999966e+00 8.05000019e+00 8.10999966e+00
 ...SHORTENED BUT 700 LONG...
 7.27480000e+04 1.00100000e+05 3.49750000e+04 3.91450000e+04], Target: [8.75       8.64099979 8. 60000038 8.64000034 8.66499996 8.52999973
 8.51000023 8.52000046 8.56000042 8.51000023 8.95499992 8.85999966
 8.75010014 8.74499989 8.75       8.76000023 8.77000046 8.64500046
 8.65200043 8.60429955 8.69999981 8.89000034 8.97999954 8.92000008
 9.21000004 9.38000011 9.47599983 9.57999992 9.46500015 9.44999981
 9.57999992 9.625      9.76000023 9.67000008 9.64000034]
Features: [8.10999966e+00 8.05000019e+00 8.10999966e+00 8.13199997e+00
 ...SHORTENED BUT 700 LONG...
 1.00100000e+05 3.49750000e+04 3.91450000e+04 6.92160000e+04], Target: [8.64099979 8.60000038 8.64000034 8.66499996 8.52999973 8.51000023
 8.52000046 8.56000042 8.51000023 8.95499992 8.85999966 8.75010014
 8.74499989 8.75       8.76000023 8.77000046 8.64500046 8.65200043
 8.60429955 8.69999981 8.89000034 8.97999954 8.92000008 9.21000004
 9.38000011 9.47599983 9.57999992 9.46500015 9.44999981 9.57999992
 9.625      9.76000023 9.67000008 9.64000034 9.56499958]
Features: [8.05000019e+00 8.10999966e+00 8.13199997e+00 8.11999989e+00
 . ..SHORTENED BUT 700 LONG...
 9.76000023 9.67000008 9.64000034 9.56499958 9.60999966], Target: [8.60000038 8.64000034 8.66499996 
 8.52999973 8.51000023 8.52000046
 8.56000042 8.51000023 8.95499992 8.85999966 8.75010014 8.74499989
 8.75       8.76000023 8.77000046 8.64500046 8.65200043 8.60429955
 8.69999981 8.89000034 8.97999954 8.92000008 9.21000004 9.38000011
 9.47599983 9.57999992 9.46500015 9.44999981 9.57999992 9.625
 9.76000023 9.67000008 9.64000034 9.56499958 9.60999966]
Features: [8.10999966e+00 8.13199997e+00 8.11999989e+00 8.06999969e+00
 ...SHORTENED BUT 700 LONG...
 3.91450000e+04 6.92160000e+04 9.24410000e+04 1.06220000e+05], Target: [8.64000034 8.66499996 8.52999973 8.51000023 8.52000046 8.56000042
 8.51000023 8.95499992 8.85999966 8.75010014 8.74499989 8.75
 8.76000023 8.77000046 8.64500046 8.65200043 8.60429955 8.69999981
 8.89000034 8.97999954 8.92000008 9.21000004 9.38000011 9.47599983
 9.57999992 9.46500015 9.44999981 9.57999992 9.625      9.76000023
 9.67000008 9.64000034 9. 56499958 9.60999966 9.63000011]
Epoch 1/5
Traceback (most recent call last):
  File "C:/Users/Technik/PycharmProjects/StockNNv1/Train.py", line 88, in <module>
    model.fit(train_dataset, epochs=EPOCHS)
  File "C:\Users\Technik\PycharmProjects\StockNNv1\venv\lib\site-packages\tensorflow\python\keras\engine\training.py", line 1100, in fit
    tmp_logs = self.train_function(iterator)
  File "C:\Users\Technik\PycharmProjects\StockNNv1\venv\lib\site-packages\tensorflow\python\eager\def_function.py", line 828, in __call__
    result = self._call(*args, **kwds)
  File "C:\Users\Technik\PycharmProjects\StockNNv1\venv\lib\site-packages\tensorflow\python\eager\def_function.py", line 871, in _call
    self._initialize(args, kwds, add_initializers_to=initializers)
  File "C:\Users\Technik\PycharmProjects\StockNNv1\venv\lib\site-packages\tensorflow\python\eager\def_function.py", line 725, in _initialize
    self._stateful_fn._get_concrete_function_internal_garbage_collected(  # pylint: disable=protected-access
  File "C:\Users\Technik\PycharmProjects\StockNNv1\venv\lib\site-packages\tensorflow\python\eager\function. py", line 2969, in _get_concrete_function_internal_garbage_collected
    graph_function, _ = self._maybe_define_function(args, kwargs)
  File "C:\Users\Technik\PycharmProjects\StockNNv1\venv\lib\site-packages\tensorflow\python\eager\function.py", line 3361, in _maybe_define_function
    graph_function = self._create_graph_function(args, kwargs)
  File "C:\Users\Technik\PycharmProjects\StockNNv1\venv\lib\site-packages\tensorflow\python\eager\function.py", line 3196, in _create_graph_function
    func_graph_module.func_graph_from_py_func(
  File "C:\Users\Technik\PycharmProjects\StockNNv1\venv\lib\site-packages\tensorflow\python\framework\func_graph.py", line 990, in func_graph_from_py_func
    func_outputs = python_func(*func_args, **func_kwargs)
  File "C:\Users\Technik\PycharmProjects\StockNNv1\venv\lib\site-packages\tensorflow\python\eager\def_function.py", line 634, in wrapped_fn
    out = weak_wrapped_fn().__wrapped__(*args, **kwds)
  File "C:\Users\Technik\PycharmProjects\StockNNv1\venv\lib\site-packages\tensorflow\python\framework\func_graph. py", line 977, in wrapper
    raise e.ag_error_metadata.to_exception(e)
ValueError: in user code:
    C:\Users\Technik\PycharmProjects\StockNNv1\venv\lib\site-packages\tensorflow\python\keras\engine\training.py:805 train_function  *
        return step_function(self, iterator)
    C:\Users\Technik\PycharmProjects\StockNNv1\venv\lib\site-packages\tensorflow\python\keras\engine\training.py:795 step_function  **
        outputs = model.distribute_strategy.run(run_step, args=(data,))
    C:\Users\Technik\PycharmProjects\StockNNv1\venv\lib\site-packages\tensorflow\python\distribute\distribute_lib.py:1259 run
        return self._extended.call_for_each_replica(fn, args=args, kwargs=kwargs)
    C:\Users\Technik\PycharmProjects\StockNNv1\venv\lib\site-packages\tensorflow\python\distribute\distribute_lib.py:2730 call_for_each_replica
        return self._call_for_each_replica(fn, args, kwargs)
    C:\Users\Technik\PycharmProjects\StockNNv1\venv\lib\site-packages\tensorflow\python\distribute\distribute_lib. py:3417 _call_for_each_replica
        return fn(*args, **kwargs)
    C:\Users\Technik\PycharmProjects\StockNNv1\venv\lib\site-packages\tensorflow\python\keras\engine\training.py:788 run_step  **
        outputs = model.train_step(data)
    C:\Users\Technik\PycharmProjects\StockNNv1\venv\lib\site-packages\tensorflow\python\keras\engine\training.py:755 train_step
        loss = self.compiled_loss(
    C:\Users\Technik\PycharmProjects\StockNNv1\venv\lib\site-packages\tensorflow\python\keras\engine\compile_utils.py:203 __call__
        loss_value = loss_obj(y_t, y_p, sample_weight=sw)
    C:\Users\Technik\PycharmProjects\StockNNv1\venv\lib\site-packages\tensorflow\python\keras\losses.py:152 __call__
        losses = call_fn(y_true, y_pred)
    C:\Users\Technik\PycharmProjects\StockNNv1\venv\lib\site-packages\tensorflow\python\keras\losses.py:256 call  **
        return ag_fn(y_true, y_pred, **self._fn_kwargs)
    C:\Users\Technik\PycharmProjects\StockNNv1\venv\lib\site-packages\tensorflow\python\util\dispatch. py:201 wrapper
        return target(*args, **kwargs)
    C:\Users\Technik\PycharmProjects\StockNNv1\venv\lib\site-packages\tensorflow\python\keras\losses.py:1537 categorical_crossentropy
        return K.categorical_crossentropy(y_true, y_pred, from_logits=from_logits)
    C:\Users\Technik\PycharmProjects\StockNNv1\venv\lib\site-packages\tensorflow\python\util\dispatch.py:201 wrapper
        return target(*args, **kwargs)
    C:\Users\Technik\PycharmProjects\StockNNv1\venv\lib\site-packages\tensorflow\python\keras\backend.py:4833 categorical_crossentropy
        target.shape.assert_is_compatible_with(output.shape)
    C:\Users\Technik\PycharmProjects\StockNNv1\venv\lib\site-packages\tensorflow\python\framework\tensor_shape.py:1134 assert_is_compatible_with
        raise ValueError("Shapes %s and %s are incompatible" % (self, other))
    ValueError: Shapes (35, 1) and (700, 35) are incompatible
Process finished with exit code 1

Sorry for the long ouput, but as it shows, the train_dataset has 700 numbers for a feature while the target has 35, that’s how I want it. (The neural network is supposed to be able to predict the 35 vlaues from 700 given ones.)

Shapes And Colors In Netlogo

 

For some phenomena, modeling the way agents look is almost as important as modeling how they behave. For others, creating pleasing and creative visualizations may simply augment our enjoyment of the modeling process and help us communicate our ideas better with others.

NetLogo includes a Turtle Shapes Editor, a Link Shapes editor, and a Color Swatches panel that allow us to create agent-based models that do not only represent real-world phenomena conceptually, but also create powerful visualizations of our agents. If you would like to learn more about how to use the shapes editors and the color swatches, read along.

Note: You can visit the NetLogo User Manual at https://ccl.northwestern.edu/netlogo/docs/ for more information on Shapes and Colors*

 


 

Turtle Shapes

In NetLogo, turtle shapes are vector shapes. They are built up from basic geometric shapes; squares, circles, and lines, rather than a grid of pixels. This way, when we resize a turtle, its image does not loose quality (i.e., does not become pixelated).

 

Default Shapes

NetLogo already has a lot of pre-designed shapes for us to use. Some of these shapes, called default shapes are embedded within each new NetLogo model. These shapes are:

And the names of these shapes are:

  • First row: default, airplane, arrow, box, bug, butterfly, car
  • Second row: circle, circle 2, cow, cylinder, dot, face happy, face neutral
  • Third row: face sad, fish, flag, flower, house, leaf, line
  • Fourth row: line half, pentagon, person, plant, sheep, square, square 2
  • Fifth row: star, target, tree, triangle, triangle 2, truck, turtle
  • Sixth row: wheel, x

 

Turtle Shapes Library

NetLogo has way more turtle shapes than the default ones for us to choose from. All we need to do is to click the Import From Library button, which will bring up a long list of shapes to choose from.

 

Creating new shapes and editing existing ones

If none of the shapes in the library fits our model, we can create new shapes from scratch by clicking the New button and drawing our own shape.

 

A few things to keep in mind while using the New Shape Editor:

  • You can pick a color that represents a changing color. That is, if you draw an object with this color, you can override this color with the set and color primitives. This color is gray by default.
  • You can uncheck the Snap the grid option to draw shapes with higher precision.
  • You can uncheck the Rotatable option to prevent your shape from being rotated when a turtle’s heading changes.
  • The name of your new shapes have to be unique. For example, if you create a tree shape, you should either name it with a different name such as «tree 2» or you should first delete the default tree shape from your model.
  • We can also Duplicate an existing shape and Edit the copied one.

 

For more detailed information, visit the Shapes Editor section of the NetLogo User Manual at https://ccl.northwestern.edu/netlogo/docs/shapes.html.

 


 

Colors

NetLogo has a custom way of representing colors that makes it easier to remember how to use them in code and how to manipulate color. Each color is assigned a number in the range 0 to 140, with the exception of 140 itself. The best way to familiarize ourselves with NetLogo colors is to click the Tools menu and pick the Color Swatches option, which will bring up a window that contains an interactive version of the following image that shows the corresponding number for each color and it’s shades:

 

 

Things to keep in mind while using NetLogo colors in code:

  • You can use the actual name of the main colors in your code such as set color green or set color violet.
  • You can use arithmetic with color names to achieve shades of a color such as set color green + 1 or set color yellow - 2. As a rule of thumb, if you add to a color, you will get a lighther shade, and if you deduct from a color, you will get a darker shade.
  • You can use decimal points for more shades such as set color green + 2.735 or set color yellow - 3.336.
  • If you are familiar with technical aspects of color representation in computing, you can use the approximate-rgb and approximate-hsb primitives to get a specific color shade.
  • You can change the increment of colors between 1, 0.5, and 0.1 using the radio buttons at the bottom of the Color Swatches window.
  • Every named color except black and white has a number ending in 5.
  • On either side of each named color are darker and lighter shades of the color.
  • 0 is pure black. 9.9 is pure white.
  • 10, 20, and so on are all so dark they are very nearly black.
  • 19.9, 29.9 and so on are all so light they are very nearly white.

 

For more detailed information, visit the Colors section of the NetLogo User Manual’s Programming Guide Section at at https://ccl.northwestern.edu/netlogo/docs/programming.html#colors.

 


 

Link Shapes

NetLogo also allows us to go beyond the simple straight lines and define a variety of custom link shapes for our models. To create new link shapes, click the Tools menu and click the Link Shapes Editor item. You will

 

 

In contrast to turtle shapes, NetLogo only has one standard link shape and there is no library, either. If we want to use a link shape other than straight line, we either need to create it from scratch by clicking the New button or import it from a previously developed model by clicking the Import from Model button.

Things to keep in mind while using the Link Shapes Editor:

  • You can change the curviness value of a link shape to make it non-linear.
  • You can design a link with one, two, and three lines using the left line, middle line, and right line parameters.
  • You cannot make a link thick by default. You need to use the thickness primitive in your code to change a link’s thickness such as ask links [ set thickness 4 ].

 

For more detailed information, visit the Shapes Editor section of the NetLogo User Manual at https://ccl.northwestern.edu/netlogo/docs/shapes.html#creating-and-editing-link-shapes.

Google Forms — Business Form Builder

Convenient questionnaires and web forms for colleagues and clients

  • Create your own web forms and questionnaires without
    special software. The data obtained through them can be analyzed in
    Google Sheets.

Start here

Contact a department representative
sales

Easy Web Form Creation

Choose questions of different types, change their sequence and answer options
no more difficult than inserting a list into a document.

Professionally designed client profiles

Neat web forms look solid and help you get the information you need.
Pictures, videos and algorithms for outputting questions will help bring the questionnaire to
perfection.

Response analysis and automatic reports

Follow real-time responses and analyze data in
Google Sheets
or other applications.

Email the form, embed it on your website, or share a link to it

Forms can be sent to respondents or posted on the website, Currents, Facebook, and Twitter.

Take Advantage of Response Checking

Data validation rules will ensure that email addresses are correctly formatted and
dates In addition, they allow you to customize the selection of questions based on previous
respondent’s answers.

Create questions and analyze results together with colleagues

You can quickly create forms with colleagues and analyze together
results without wasting time e-mailing different versions of files
mail.

With Google Forms, getting information from customers has become much easier.
It is enough to create and send out a questionnaire, and the answers appear in a single table in
real time mode.

Justin Hiltz

Johnny Cupcakes

More

Do I need a Google account to fill out the form?

No. Google Forms can be filled out by anyone.

Can I make a form only available within an organization?

Yes. Specify in the form settings who can open and edit it.

Does Google Forms support a large number of responses?

Yes. You can process as much data with Google Forms as with
Google Sheets.
And that’s two million cells!

Register today — it’s easy

You can contact our support specialists by phone for help,
e-mail and chat at any time of the day.

Start
here

Create a form using Microsoft Forms

Tip:
Learn more about Microsoft Forms, or get started right away and create a survey, quiz, or quiz. Want to use more advanced branding, question types, and data analysis? Try Dynamics 365 Customer Voice.

You can use Microsoft Forms to create surveys and tests, and view results as they come in.

Note: Creating a test? Start from here!

Starting a new form

  1. Navigate Microsoft Forms with a Microsoft 365 school, Microsoft 365 work credential, or a Microsoft account (Hotmail, Live, or Outlook.com).

    Note: You can also sign in to Office.com, find the Microsoft 365 icons on the left, and then select Forms .

  2. Select «New form» .

  3. The title of the form and optionally a description.

    Note: Form titles can be up to 90 characters long. The description can contain up to 1000 characters.

    Note: The created form is saved automatically.

Adding questions

  1. Select add new to add a new question to the form.

  2. Select the type of question you want to add, such as «Choice «, «Text «, « Rating» or «Date «. Select other question types for question types ranking , Likert , file upload or net Promoter Score® . To organize sections for questions, select «Section» .

    Tip: You can also format the text. Highlight the word or words in the title or questions, and then select any of the following options: bold (keyboard shortcut — CTRL/CMD+ B), italic (keyboard shortcut — CTRL/CMD+ I), underline (keyboard shortcut — CTRL/CMD+ U), color font , font size , numbering or bullets .

    Important: If you delete a question, it will be permanently deleted along with any response data collected for it. Read more…

Form preview

  1. org/ListItem»>

    On a computer, select preview to see what the form will look like. On a mobile device, select to see what the form will look like.

  2. To test the form, answer the questions in Preview and click the Submit button .

  3. To change the form, press the back button .

New mold launch

  1. Sign in to Microsoft 365 with your work or school account.

  2. Select new > Forms for Excel .

    Note:

    Forms for Excel
    is only available for OneDrive for work or school and new team sites connected to Microsoft 365 Groups. Learn more about Microsoft 365 Groups.

  3. Enter a name for the form and click New . A new tab for Microsoft Forms will open in your web browser.

    Note: Form titles can be up to 90 characters long. The description can contain up to 1000 characters.

    Note: The created form is saved automatically.

Adding questions

  1. Select add new to add a new question to the form.

  2. Select the type of question you want to add, for example «Choice «, «Text «, « Score» or «Date «. Select other question types for question types ranking , Likert , upload files or net Promoter Score® . To organize the sections for questions, select «Section»

    Tip: You can also format the text. Highlight a word or words in the title or questions, then select any of the following options: bold (shortcut — CTRL/CMD+ B), italic (shortcut — CTRL/CMD+ I), underline (shortcut — CTRL/CMD+ U), font color , font size , numbering or markers .

    Important: If you delete a question, it will be permanently deleted along with any response data collected for it. Read more…

Form preview

  1. Select preview, to see what the form will look like.

  2. To test the form, answer the questions in Preview and click the Submit button .

  3. To change the form, press the back button .

New mold launch

  1. Sign in to Microsoft 365 with your work or school account.

  2. Open the Excel workbook where you want to paste the form.

  3. Select «Insert > forms > «New Form» .

    Note: To enable the Forms button, make sure your Excel workbook is stored on OneDrive for work or school. Also note , Forms for Excel is only available for OneDrive for work or school and new team sites connected to Microsoft 365 Groups. Learn more about Microsoft 365 Groups.

  4. A new tab for Microsoft Forms opens in a web browser.

  5. Select a default placeholder title and modify it yourself. If necessary, also add a description.

    Note: Form titles can contain up to 90 characters. The description can contain up to 1000 characters.

    Note: The created form is saved automatically.

Adding questions

  1. org/ListItem»>

    Select add new to add a new question to the form.

  2. Select the type of question you want to add, such as «Choice «, «Text «, « Rating» or «Date «. Select other question types for question types ranking , Likert , file upload or net Promoter Score® . To organize sections for questions, select «Section» .

    Tip: You can also format the text. Highlight the word or words in the title or questions, and then select any of the following options: bold (keyboard shortcut — CTRL/CMD+ B), italic (keyboard shortcut — CTRL/CMD+ I), underline (keyboard shortcut — CTRL/CMD+ U), color font , font size , numbering or bullets .

    Important: If you delete a question, it will be permanently deleted along with any response data collected for it. Read more…

Form preview

  1. Select Preview to see how the form will look on a computer or mobile device.

  2. To test the form, answer the questions in preview mode and click Submit « .

  3. To change the form, press the back button .

New mold launch

  1. Sign in to Microsoft 365 with your school account.

    Note: This feature only applies to Office 365 Class or Teacher Notebooks for Education users. Learn more about OneNote Class Notebook and OneNote Office Notebook.

  2. Open the OneNote notebook where you want to insert the form.

  3. On the tab Insert , click the button Form .

    Note:
    The Forms button is only available for Office 365 Education users. To access OneNote forms for the web, sign in with your school account.

  4. Forms panel for OneNote 9 opens0066 , which will be pinned to the right side of the OneNote notebook.

  5. In the «My Forms » section, select «New Form» .

  6. A new tab for Microsoft Forms opens in a web browser.

  7. org/ListItem»>

    Select a default placeholder title and update it with your own title. If necessary, also add a description.

    Note: Form titles can be up to 90 characters long. The description can contain up to 1000 characters.

    Note: The created form is saved automatically.

Adding questions

  1. Select add new to add a new question to the form.

  2. Select the type of question you want to add, such as «Choice «, «Text «, « Rating» or «Date «. Select other question types for 9 question types0065 ranking , Likert , sending files or net Promoter Score® . To organize sections for questions, select «Section» .

    Tip: You can also format the text. Highlight the word or words in the title or questions, and then select any of the following options: bold (shortcut — CTRL/CMD+ B), italic (shortcut — CTRL/CMD+ I), underline (keyboard shortcut is CTRL/CMD+ U), font color , font size , numbering or bullets .

    Important: If you delete a question, it will be permanently deleted along with any response data collected for it. Read more…

Form preview

  1. org/ListItem»>

    Select Preview to see how the form will look on a computer or mobile device.

  2. To test the form, answer the questions in Preview and click the Submit button .

  3. To change the form, press the back button .

The generated form will appear at the top of the My Forms list in the Forms for OneNote panel and can be embedded in a OneNote notebook. Read more…

Additional resources

Now that you have the basics, you can also customize the theme of the form, add a picture to the question, create sections, use branching logic, and more.

By alexxlab

Similar Posts