- 已关闭。**此问题为not reproducible or was caused by typos。目前不接受答案。
这个问题是由一个打字错误或一个无法再重现的问题引起的。虽然类似的问题在这里可能是on-topic,但这个问题的解决方式不太可能帮助未来的读者。
5小时前关门了。
Improve this question
我正在尝试对视网膜OCT图像(光学相干断层扫描)进行分类
1.正常
1.德鲁森
model = Sequential();
model.add((Conv2D(32,kernel_size = 5,input_shape=(img_height,img_width,3),activation="relu"))) model.add((Conv2D(32,kernel_size = 5,activation="relu")))
model.add((Conv2D(64,kernel_size = 4,activation="relu")))
model.add((Conv2D(64,kernel_size = 4,activation="relu")))
model.add(MaxPooling2D(pool_size=2))
model.add(Dropout(0.2))
model.add((Conv2D(32,kernel_size = 5,activation="relu")))
model.add((Conv2D(64,kernel_size = 4,activation="relu")))
model.add((Conv2D(64,kernel_size = 4,activation="relu")))
model.add(MaxPooling2D(pool_size=2))
model.add(Dropout(0.2))
model.add((Conv2D(32,kernel_size = 4,activation="relu")))
model.add(MaxPooling2D(pool_size=2))
model.add((Conv2D(64,kernel_size = 3,activation="relu")))
model.add((Conv2D(64,kernel_size = 3,activation="relu")))
model.add(MaxPooling2D(pool_size=2))
model.add(Dropout(0.2))
model.add(Flatten())
model.add(Dense(1024,activation="relu"))
model.add(Dropout(0.2))
model.add(Dense(512,activation="relu"))
model.add(Dropout(0.2))
model.add(Dense(4,activation="softmax"))
model.compile(optimizer = SGD(lr=0.001,momentum = 0.9),loss="categorical_crossentropy",metrics=['accuracy'])
model.built(input_shape = (img_height,img_width,3))
model.summary()
以上是我的模型误差是
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
/tmp/ipykernel_23/2596533629.py in <module>
28
29 model.compile(optimizer = SGD(lr=0.001,momentum = 0.9),loss="categorical_crossentropy",metrics=['accuracy'])
---> 30 model.built(input_shape = (img_height,img_width,3))
31 model.summary()
TypeError: 'bool' object is not callable
它显示
ValueError Traceback (most recent call last)
/tmp/ipykernel_23/3973631267.py in <module>
29 model.compile(optimizer = SGD(lr=0.001,momentum = 0.9),loss="categorical_crossentropy",metrics=['accuracy'])
30 # model.built(input_shape = (img_height,img_width,3))
---> 31 model.summary()
/opt/conda/lib/python3.7/site-packages/keras/engine/training.py in summary(self, line_length, positions, print_fn)
2519 """
2520 if not self.built:
-> 2521 raise ValueError('This model has not yet been built. '
2522 'Build the model first by calling `build()` or calling '
2523 '`fit()` with some data, or specify '
ValueError: This model has not yet been built. Build the model first by calling `build()` or calling `fit()` with some data, or specify an `input_shape` argument in the first layer(s) for automatic build.
在添加模型之前。built(input_shape =(img_height,img_width,3))行
1条答案
按热度按时间qv7cva1a1#
the type of bool returned when no type matches and it is string operations that are programming logics but for your question answer is the correct function model.build(input_shape = (img_height,img_width,3)).
The model.build() inherits from class benefits when you have multiple of model variables and reuse it.
Sample: From the question, the method name is model.build() and input is enough for its dimension.
示例:执行继承类的测试,函数build()内部包含初始权重,执行时必须正确预期。
Output: The results after calling the function build are different we are expecting the same behavior from the model.build(). The initial value is important because in some problem equations critical points can have more than one and we do not want to skip some small steps. Recalling the build() function that is you start from the same alignment as find a and b from ax + b = y.