'What is the problem in this keras input shape?
from matplotlib import units
import numpy as np
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense
from tensorflow.keras import optimizers
from tensorflow import keras
x_test = np.array([[0,0,0,0,0],[1,1,1,1,1]])
x_data = np.array([[[0,0,0,0,0],[1,1,1,1,1]],
[[1,1,1,1,1],[0,0,0,0,0]]])
y_data = np.array([[0],[1]])
model = Sequential([
Dense(2,activation='sigmoid'),
Dense(1,activation='sigmoid')
]
)
sgd = optimizers.SGD(learning_rate = 0.001)
model.compile(loss='mse', optimizer=sgd, metrics=['mse'])
# model fit
history = model.fit(x_data, y_data, batch_size=1, epochs=400, shuffle=False, verbose=1) # prediction
print (model.predict(x_test))
I want to get one output but when I do program it output like [[[~~],[~~]]] this. iNPUT WHEN x is [[[1,1,1,1,1],[0,0,0,0,0]]] out [0] when x is [[[0,0,0,0,0],[1,1,1,1,1]]] out [1] (this case is just an example) what's the problem?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|