from keras.models import Sequential
from keras.layers import Dense,Activation
model = Sequential([
Dense(32,input_shape=(784,)),
Activation('relu'),
Dense(10),
Activation('softmax'),
])
model = Sequential()
model.add(Dense(32, input_dim=784))
model.add(Activation=('relu'))
-------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-3-8fbf2d71ffd0> in <module> 1 model = Sequential() 2 model.add(Dense(32, input_dim=784)) ----> 3 model.add(Activation=('relu')) ~\anaconda3\envs\ten\lib\site-packages\tensorflow\python\training\tracking\base.py in _method_wrapper(self, *args, **kwargs) 515 self._self_setattr_tracking = False # pylint: disable=protected-access 516 try: --> 517 result = method(self, *args, **kwargs) 518 finally: 519 self._self_setattr_tracking = previous_value # pylint: disable=protected-access TypeError: add() got an unexpected keyword argument 'Activation'
深度学习小白,刚开始学习keras,想问下这是什么情况应该怎么弄呀
哦哦,我知道了,你的问题应该是activation开头字母大小写的问题
Activation后面多了等于号 =
你的激活函数是啥。要确定啊。有好几中目前常用的是RELU
activation只是告诉系统你在增加一个激活层,但是这个激活层是什么样子的?是relu?是sigmoid?还是其他的样子,需要你自己定义一下。一般用的多的就是relu。
按照你的写法应该改为 model.add(layers.Dense(activation='relu'))