如何初始化集合中的一些变量?
05-16 09:23:16.697 19724-19724/com.messenger.nillrong E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.messenger.nillrong, PID: 19724
java.lang.IndexOutOfBoundsException: Inconsistency detected. Invalid item position 8(offset:8).state:9 android.support.v7.widget.RecyclerView{58bee7e VFED..... .F...... 0,0-1080,1845 #7f08007b app:id/recyclerViewId}, adapter:com.messenger.nillrong.MyRecyclerAdapter@2b31fdf, layout:android.support.v7.widget.LinearLayoutManager@f74b42c, context:com.messenger.nillrong.MainActivity@5452394
at android.support.v7.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:5817)
at android.support.v7.widget.GapWorker.prefetchPositionWithDeadline(GapWorker.java:285)
at android.support.v7.widget.GapWorker.flushTaskWithDeadline(GapWorker.java:342)
at android.support.v7.widget.GapWorker.flushTasksWithDeadline(GapWorker.java:358)
at android.support.v7.widget.GapWorker.prefetch(GapWorker.java:365)
at android.support.v7.widget.GapWorker.run(GapWorker.java:396)
at android.os.Handler.handleCallback(Handler.java:754)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:163)
at android.app.ActivityThread.main(ActivityThread.java:6342)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:880)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:770)
05-16 09:23:16.765 19724-19724/com.messenger.nillrong I/Process: Sending signa
答案 0 :(得分:0)
只需将集合中的变量列表传递给https://www.tensorflow.org/api_docs/python/tf/variables_initializer即可获得初始化这些变量的操作。
vars = tf.get_collection('my_collection_name')
vars_init_op = tf.variables_initializer(vars)
sess.run(vars_init_op)