admin管理员组

文章数量:1410689

In tensorflow, given a model h = Model(input_layer, output_layer) for example (its summary looks like below)

Model: "functional_1"
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┓
┃ Layer (type)                    ┃ Output Shape           ┃       Param # ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━┩
│ input_layer (InputLayer)        │ (None, 784)            │             0 │
├─────────────────────────────────┼────────────────────────┼───────────────┤
│ dense (Dense)                   │ (None, 64)             │        50,240 │
├─────────────────────────────────┼────────────────────────┼───────────────┤
│ dense_1 (Dense)                 │ (None, 32)             │         2,080 │
├─────────────────────────────────┼────────────────────────┼───────────────┤
│ dense_2 (Dense)                 │ (None, 64)             │         2,112 │
├─────────────────────────────────┼────────────────────────┼───────────────┤
│ dense_3 (Dense)                 │ (None, 784)            │        50,960 │
└─────────────────────────────────┴────────────────────────┴───────────────┘
 Total params: 105,392 (411.69 KB)
 Trainable params: 105,392 (411.69 KB)
 Non-trainable params: 0 (0.00 B)

If I want to change the number of neurons of dense_1 from 32 to 16, is there any easy and handy way to update the new configuration?

I tried h.layers[2].units = 16, which unfortunately didn't change the model setup at all. I am wondering if there is kind of "assignment" operation to do that.

本文标签: