How to expand a Tensorflow Variable -


is there way make tensorflow variable larger? like, let's wanted add neuron layer of neural network in middle of training. how go doing that? answer in this question told me how change shape of variable, expand fit row of weights, don't know how initialize new weights.

i figure way of going might involve combining variables, in initializing weights first in second variable , adding in new row or column of first variable, can't find lets me either.

there various ways accomplish this.

1) second answer in post (https://stackoverflow.com/a/33662680/5548115) explains how can change shape of variable calling 'assign' validate_shape=false. example, like

# assume var [m, n]  # add new 'data' of shape [1, n] new values new_neuron = tf.constant(...)    # if concatenating add row, concat on first dimension. # if new_neuron [m, 1], concat on second dimension. new_variable_data = tf.concat(0, [var, new_neuron])  # [m+1, n]  resize_var = tf.assign(var, new_variable_data, validate_shape=false) 

then when run resize_var, data pointed 'var' have updated data.

2) create large initial variable, , call tf.slice on different regions of variable training progresses, since can dynamically change 'begin' , 'size' attributes of slice.


Comments

Popular posts from this blog

android - Why am I getting the message 'Youractivity.java is not an activity subclass or alias' -

Making Empty C++ Project: General exception (Exception from HRESULT:0x80131500) Visual Studio Community 2015 -

How to fix java warning for "The value of the local variable is not used " -