Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Bug] Discrepancy in tf.keras and keras in setting model.trainable = False and then compiling #22012

Closed
Assignees
fchollet
@naoto0804

Description

@naoto0804

System information

  • Have I written custom code: Yes
  • OS Platform and Distribution: Linux Ubuntu 16.04
  • TensorFlow installed from: binary
  • TensorFlow version: v1.10.1-0-g4dcfddc5d1 1.10.1
  • Bazel version: N/A
  • CUDA/cuDNN version: CUDA9.1, cuDNN7.0
  • GPU model and memory: TITAN V
  • Exact command to reproduce: python3 compare.py
  • Mobile device: N/A

Describe the problem

This is a toy case for training GAN problem.
When I run the code shown below in keras2.2.2, I get

WARNING:tensorflow:Discrepancy between trainable weights and collected trainable weights, did you set `model.trainable` without calling `model.compile` after ?

only at the beginning of the training once.
However, I run this code in tensorflow1.10.1, the warning raises at every iteration.
Although it seems that the model is appropriately learned (I can make sure the weight is freezed by the result of.summary()), raising too many warning is not torelable.

Here is the complete log.
tf.keras ver
keras ver

I see the same problem is posted in Stackoverflow
https://stackoverflow.com/questions/50468940/tensorflow-1-8-tf-keras-gives-different-result-in-dcgan-from-keras

import numpy as np# use kerasfrom keras.layers import Dense, Inputfrom keras.models import Model# use tf.keras# from tensorflow.keras.layers import Dense, Input# from tensorflow.keras.models import Model# define inputnoise = Input(shape=(10,))x = Input(shape=(100,))# define generator and discriminatorgen = Dense(100)dis = Dense(1)y = dis(x)dis_model = Model(x, y)dis_model.compile(optimizer='rmsprop', loss='mse')dis_model.summary()z = dis_model(gen(noise))dis_model.trainable = Falsecombined_model = Model(noise, z)combined_model.compile(optimizer='rmsprop', loss='mse')combined_model.summary()for i in range(3):    dis_model.train_on_batch(x=np.random.rand(10, 100),                             y=np.random.rand(10, 1))    combined_model.train_on_batch(x=np.random.rand(10, 10),                             y=np.random.rand(10, 1))

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp