据我所知,我的神经网络只有2层LSTM和输出层,但是当我打印出每层的重量时,我得到了一个空重的额外层。谁能澄清这个输出还是我的理解是错的?
它的time_step为7,num_input为3,输出为2.退出率为0.5。
即使没有经过训练,这种神经网络输出也会产生相同的输出,无论输入是什么。我试图调试它。
代码:
model.add(LSTM(12, input_shape=(time_steps, num_input), activation='relu', unit_forget_bias=True, bias_initializer='zeros', kernel_initializer=initializers.RandomUniform(minval=-1, maxval=1), recurrent_activation='relu'))
model.add(Dropout(dropout))
model.add(Dense(num_output, activation='softmax', kernel_initializer=initializers.RandomUniform(minval=-1, maxval=1)))
model.compile(loss=loss_function, optimizer=optimizer_function, metrics=['acc'])
counter = 0
for layer in model.layers:
print(counter, layer.get_weights())
counter += 1
输出:
0 [array([[-0.24521542, -0.70160842, 0.27366495, -0.27743888, 0.75009584,
0.25599909, 0.38801599, -0.20273829, -0.07191849, 0.27447796,
-0.00708866, -0.00666118, 0.17631078, 0.02666068, -0.07738662,
0.33693957, 0.96345758, 0.71073961, 0.44208169, 0.6945982 ,
0.64919782, -0.52719903, 0.12036228, 0.60486031, 0.51799178,
-0.75186992, -0.28580689, -0.19886994, 0.49282694, 0.83806777,
0.00712466, -0.62782884, 0.04944801, 0.7866354 , 0.28580236,
-0.25791597, 0.99613404, 0.72680449, -0.73945332, 0.79622149,
0.39543009, 0.15706682, 0.58931088, 0.88239527, -0.80051279,
0.52861094, 0.77886581, 0.80290627],
[ 0.7546804 , -0.48624468, -0.15527534, -0.70569277, 0.86888766,
0.48139691, -0.19293284, 0.42512822, -0.99511337, 0.03062463,
0.12436891, -0.87743688, 0.24677491, -0.16390824, 0.05924869,
-0.75485945, -0.51627636, 0.92178059, -0.95354581, -0.10260463,
-0.04684424, 0.01882982, -0.62982488, 0.87434769, -0.39813781,
-0.3045814 , -0.91332555, -0.1598289 , 0.35212064, 0.17643642,
0.52914667, 0.36753321, -0.05140471, 0.77591944, -0.785537 ,
0.76745152, -0.7325809 , -0.88412356, 0.74923658, -0.30762291,
-0.75603771, -0.8112607 , -0.91697383, -0.54521894, -0.51775885,
0.30885959, -0.22136259, -0.66382146],
[ 0.26065445, 0.48088837, -0.94533539, 0.01412749, -0.16286325,
0.88329911, -0.68435764, -0.32847238, -0.3569994 , 0.00744963,
0.37743616, -0.8640151 , 0.42867732, -0.71146655, 0.3011651 ,
0.80415225, -0.98356128, -0.14065552, 0.26375103, -0.11873388,
0.01047683, 0.40524793, 0.69572425, -0.15699077, -0.21437597,
-0.17017817, -0.29662871, -0.61970282, -0.80687809, 0.17843056,
-0.61833644, 0.22320771, -0.04641867, 0.50721407, -0.96682215,
-0.95549297, -0.43905139, -0.20920539, -0.69045758, 0.24916172,
0.71746254, -0.90135694, -0.02756333, 0.85385418, -0.17386127,
-0.6222682 , -0.18429565, 0.38925314]], dtype=float32), array([[-0.02033471, 0.35036457, -0.22910373, 0.00760625, 0.2043882 ,
0.11738618, -0.08864721, 0.01498185, 0.26989809, 0.21553771,
-0.05318699, -0.22805944, -0.02447774, 0.19338799, 0.12499192,
0.06640412, 0.07907286, 0.08237705, 0.04068918, -0.07288828,
-0.02745646, 0.1590983 , 0.13237894, 0.34082556, -0.1463456 ,
0.06416136, -0.05991739, -0.18373621, -0.08630949, -0.01693073,
-0.04433511, 0.30036968, -0.00352106, 0.01008222, -0.01238813,
-0.09504303, 0.09013844, -0.14845927, -0.14517047, 0.14843805,
0.11790767, 0.02793198, 0.06459343, 0.06467769, 0.06598908,
-0.23322476, -0.03217521, 0.14322996],
[ 0.05864402, 0.07922871, 0.07378255, 0.04546327, 0.01927931,
0.18573418, -0.159896 , 0.02487363, 0.02383794, -0.20636876,
-0.02224975, 0.20493619, 0.22222976, -0.09418963, 0.0355754 ,
-0.16385514, 0.1784135 , 0.19803056, -0.01829438, -0.06000176,
0.21078815, -0.22398581, -0.06617181, 0.15193403, -0.11811844,
0.13475136, -0.31193998, 0.00333052, -0.09486151, 0.20512965,
-0.12429255, -0.10136144, 0.0240426 , -0.0179066 , -0.22667909,
-0.03775523, 0.0684068 , 0.07891367, 0.02093293, -0.10532314,
0.10350898, -0.05209668, -0.04242592, -0.36924657, 0.04319758,
-0.2742556 , 0.09543416, -0.18032318],
[ 0.03556766, 0.05535906, 0.02675538, -0.02131121, 0.26054731,
-0.09065662, -0.15470752, 0.02705213, 0.03218656, -0.28294089,
-0.1241535 , -0.03728139, 0.05195143, -0.22098057, 0.05037116,
-0.11720208, 0.07683843, -0.1193686 , -0.22540359, -0.16058175,
0.04342809, -0.01308457, -0.18741629, -0.063871 , -0.02473109,
-0.33817884, -0.01401741, 0.1469952 , 0.02203038, -0.01378152,
0.00996919, 0.10832896, 0.10883206, -0.0299022 , 0.25817832,
-0.18097696, 0.09837963, -0.26886559, 0.21029587, 0.23133136,
0.06430923, -0.08498586, 0.3173219 , -0.0478869 , 0.13538593,
0.08697879, -0.09221876, -0.01162537],
[-0.05401393, 0.06125088, 0.23440452, -0.06260482, 0.03913982,
-0.14856239, -0.02149021, 0.21849351, 0.20043746, -0.09506505,
-0.00982449, -0.09573822, -0.22466341, 0.22394681, -0.2147858 ,
0.06025937, -0.03828581, -0.00167759, -0.03305264, -0.23886602,
0.17675708, -0.0092163 , -0.0167509 , 0.04083197, 0.08696942,
-0.03983665, -0.03215779, 0.12096903, 0.19513203, 0.24121523,
-0.09233849, 0.07302081, 0.1582018 , -0.02135381, 0.20214865,
-0.2333072 , -0.13499814, -0.02135884, -0.11316242, -0.34329945,
-0.2342732 , 0.05534038, -0.1002339 , 0.07087246, -0.0139307 ,
-0.12557672, 0.25842258, -0.00906693],
[-0.3691411 , -0.20162676, 0.02531274, -0.05095335, 0.21560751,
-0.14882837, 0.01329543, -0.07940496, -0.06948807, 0.22213475,
-0.24376036, 0.17134094, 0.22963829, -0.04603028, -0.07653585,
0.06974904, 0.08805051, 0.0361966 , -0.10852201, 0.07912195,
-0.06465252, 0.01856732, 0.21850535, 0.21364164, -0.12931682,
0.02285584, 0.1271527 , -0.17278516, 0.07559054, 0.09732898,
-0.04404632, -0.19681202, -0.06003241, -0.12298001, 0.11505324,
-0.20419037, -0.2508668 , -0.1274903 , 0.04451947, -0.07883096,
-0.11704427, 0.18670546, 0.05032831, -0.1164139 , 0.01936312,
-0.02296325, -0.21579987, -0.13748147],
[ 0.04260362, 0.00762554, -0.07162373, 0.03100744, -0.19107912,
-0.08416328, -0.05336539, 0.03323252, -0.01961052, 0.40443578,
-0.24548431, 0.05731211, 0.05728706, -0.05157589, 0.00268018,
-0.1519298 , -0.06639624, 0.15809853, -0.00273514, -0.41929573,
0.02783292, 0.0678527 , 0.08088325, 0.01352766, 0.18033364,
0.22313675, 0.08921089, 0.10697351, 0.22069024, 0.00937657,
0.01461298, 0.01710716, 0.21329141, 0.06096657, -0.13535568,
-0.01004616, -0.0111774 , 0.06089412, 0.19857614, -0.05482864,
0.08520801, -0.26553917, 0.20397952, -0.14985719, 0.05710589,
0.16448419, 0.01346221, 0.18271512],
[-0.05295208, 0.2243471 , 0.17107718, -0.30323064, -0.00788007,
-0.11950868, 0.24900137, -0.21288717, -0.03036776, 0.11939076,
-0.02417958, 0.02557938, 0.03513969, -0.02777558, -0.06980747,
-0.0185275 , -0.06350167, 0.01700263, -0.22184421, -0.06240473,
0.12922326, 0.37910423, -0.11080422, -0.13848746, 0.02415096,
-0.17376019, 0.0525399 , -0.08634372, -0.15843505, 0.05735993,
-0.09645485, -0.06318427, -0.09628739, -0.00575478, -0.37868378,
-0.06525372, 0.25985357, -0.17358606, -0.06864014, -0.08131886,
0.03705063, 0.10135308, 0.04662868, -0.07647421, -0.15614538,
0.05403953, 0.16817404, -0.08463066],
[ 0.17623845, -0.15794764, -0.04160334, -0.13513324, 0.21663484,
0.19407599, 0.10787451, -0.02537039, 0.12182101, 0.03565344,
0.17000458, 0.00349261, 0.02175007, 0.08370995, 0.11974211,
0.14470729, -0.08181615, 0.0552465 , -0.13478576, -0.05293605,
0.21553941, -0.32911152, 0.06520491, 0.04304377, 0.03740592,
-0.01165924, 0.15674426, 0.09790639, -0.01096018, -0.11590454,
-0.0511469 , 0.23025918, -0.02462219, -0.26048404, -0.30032566,
0.08880173, -0.29021269, -0.00818963, 0.04883815, 0.01467158,
-0.12270398, 0.19118902, 0.29459879, -0.02962655, -0.02923334,
0.17779331, 0.13123691, -0.02180249],
[ 0.0406248 , -0.0628924 , 0.25276813, 0.09493993, -0.18715475,
-0.04871836, 0.04059317, -0.13940312, 0.01072847, -0.00143248,
0.28100935, -0.04627981, 0.03196833, 0.07120232, 0.07290287,
-0.13559093, 0.02735679, 0.22925262, 0.0404184 , 0.01314906,
0.10446987, 0.0190053 , 0.03544032, 0.16709638, 0.05228996,
-0.3367106 , -0.13968703, -0.16469303, 0.23213567, -0.16272104,
0.00153116, -0.22684756, 0.39004198, -0.17515612, -0.0731611 ,
-0.05011011, -0.02349407, 0.00515303, -0.09741961, 0.07983034,
0.09564134, 0.12932387, 0.09508701, 0.12182487, -0.04965768,
-0.10650358, -0.23383772, 0.19103175],
[ 0.01548704, -0.29555339, 0.05715664, -0.16189465, 0.03499255,
0.21402009, -0.09664325, -0.02386762, 0.3317377 , 0.0967191 ,
0.00617218, 0.08791035, -0.07249293, -0.01702965, 0.28173098,
-0.05189466, 0.16439016, -0.17383827, -0.15582241, 0.18802027,
0.01917838, 0.07647445, 0.15948787, 0.0878301 , 0.03346422,
0.07002883, 0.06093212, 0.05227378, -0.0818451 , 0.17109218,
-0.06212406, -0.12410983, 0.33803824, 0.12105033, 0.02402613,
0.07761155, 0.33019975, -0.02377768, -0.11400606, -0.0909552 ,
-0.16028784, -0.17264588, 0.0084119 , 0.14556548, 0.01698433,
0.17410459, -0.02737463, -0.11298372],
[ 0.3221916 , -0.13795164, 0.16254824, 0.17292848, -0.10435951,
-0.01355793, -0.16088085, 0.09203475, -0.17928492, 0.0642034 ,
0.01287666, 0.07464992, 0.24870317, 0.13904518, 0.07857218,
-0.11355306, -0.12257951, 0.22196048, -0.06356272, 0.03277521,
-0.03949503, 0.00986036, 0.09513797, -0.16556983, -0.12827548,
0.026578 , 0.26690841, -0.05049543, 0.04815316, 0.20526268,
-0.14276674, 0.18441732, -0.10276154, 0.22870025, 0.11240374,
-0.21866821, 0.09622572, -0.00426483, -0.23028791, 0.19355921,
-0.00599831, 0.13047583, 0.16049533, 0.13316454, -0.15122548,
-0.05988484, 0.0807161 , -0.13862035],
[-0.20290378, 0.0447388 , 0.00251961, 0.28006148, 0.25653204,
0.00534883, 0.10078116, 0.02890838, -0.0326261 , -0.08573683,
0.08485619, 0.07575557, -0.1360961 , -0.18079524, 0.15826732,
-0.3027634 , 0.01673756, 0.14736931, -0.04465336, -0.25784078,
-0.12580903, 0.10712094, 0.08812711, 0.07716106, 0.03651243,
-0.12892573, 0.01697676, 0.08949891, -0.19950908, 0.23513792,
-0.06774111, 0.06022764, -0.11096187, -0.01119936, -0.16933256,
0.0597085 , -0.12040415, 0.23257086, 0.08027195, 0.03882086,
-0.21593039, -0.08365598, -0.08527714, 0.28556687, -0.2665146 ,
0.00986508, -0.11322719, 0.06011448]], dtype=float32), array([ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.,
1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0.], dtype=float32)]
1 []
2 [array([[ 0.75362301, 0.43799639],
[ 0.98578501, 0.0380733 ],
[-0.38638234, -0.44162703],
[ 0.06233907, -0.50022388],
[-0.65105438, 0.90983796],
[ 0.00867295, 0.28238487],
[-0.1554873 , -0.33650756],
[-0.40741014, 0.65137649],
[ 0.54700851, -0.79713511],
[-0.94714022, -0.8237114 ],
[-0.7994988 , 0.41735601],
[-0.24323153, 0.59699798]], dtype=float32), array([ 0., 0.], dtype=float32)]
答案 0 :(得分:0)
重量打印中的空白层1导致:
model.add(Dropout(dropout))