Python: Error occurred when learning with Tensorflow using levenberg marquardt library

88
April 04, 2022, at 8:30 PM

I'm new to Tensorflow. I'm trying to create a network like this: ・ Input layer: 400 pieces ・ Hidden layer: 20 pieces, activation functions tanh ・ Output layer: 1 pieces, activation function sigmoid ・ Optimization method: levenberg marquardt ・ Library used: https://github.com/fabiodimarco/tf-levenberg-marquardt

Please tell me what is wrong.

Code:

x_train = tf.cast(x_train / 3., dtype=tf.float32)
    x_test = tf.cast(x_test / 3. , dtype=tf.float32)
    y_train = tf.cast(y_train, dtype=tf.float32)
    y_test = tf.cast(y_test, dtype=tf.float32)
    train_dataset = tf.data.Dataset.from_tensor_slices((x_train, y_train))
    model = tf.keras.models.Sequential([
        keras.layers.Dense(20, activation='tanh', use_bias=True, input_shape=(4 * frame_num, 1)),
        keras.layers.Dense(1, activation='sigmoid')
    ])
    model_wrapper = lm.ModelWrapper(model)
    model_wrapper.compile(
        optimizer=tf.keras.optimizers.SGD(learning_rate=1.0),
        loss=lm.MeanSquaredError()
    )
    model_wrapper.fit(train_dataset)
    test_loss, test_acc = model_wrapper.evaluate(x=x_test, y=y_test, verbose=0)
    print("test_loss: %f - test_accuracy: %f" % (test_loss, test_acc))

error

Input 0 of layer "dense" is incompatible with the layer: expected axis -1 of input shape to have value 400, but received input with shape (None, 1)
Call arguments received:
  • inputs=tf.Tensor(shape=(None, 1), dtype=float32)
  • training=None
  • mask=None

thanks, Wlix

Rent Charter Buses Company
READ ALSO
How to open a new MDI sub-window in PyQt5?

How to open a new MDI sub-window in PyQt5?

What I want to do is to open a new Countrypage sub-window by clicking on the "New" button which is in Countrypage itself

118
Finding optimal nearest neighbour pairs

Finding optimal nearest neighbour pairs

I am writing a "colocalization" script to identify unique co-localized pairs of coordinates between two sets of dataMy data is quite large with <100k points in each set so performance is pretty important

114
Send raw hex and strings over sockets

Send raw hex and strings over sockets

I'm trying to send data over sockets with Python to trigger IDS rules

128
Why is my csv file not printing after I import it?

Why is my csv file not printing after I import it?

and still not receiving anything? It does not even come up with an error

78