コード例 #1
0
ファイル: test_layers_eager.py プロジェクト: zzachw/deepchem
 def test_sigmoid(self):
     """Test invoking Sigmoid in eager mode."""
     with context.eager_mode():
         input = np.random.rand(5, 10).astype(np.float32)
         result = layers.Sigmoid()(input)
         expected = tf.nn.sigmoid(input)
         assert np.allclose(result, expected)
コード例 #2
0
                                 in_layers=concat1)
concat2 = layers.Concat(in_layers=[conv2, deconv1], axis=3)
deconv2 = layers.Conv2DTranspose(16,
                                 kernel_size=5,
                                 stride=2,
                                 in_layers=concat2)
concat3 = layers.Concat(in_layers=[conv1, deconv2], axis=3)
deconv3 = layers.Conv2DTranspose(1, kernel_size=5, stride=2, in_layers=concat3)
# Compute the final output.
concat4 = layers.Concat(in_layers=[features, deconv3], axis=3)
logits = layers.Conv2D(1,
                       kernel_size=5,
                       stride=1,
                       activation_fn=None,
                       in_layers=concat4)
output = layers.Sigmoid(logits)
model.add_output(output)
loss = layers.ReduceSum(layers.SigmoidCrossEntropy(in_layers=(labels, logits)))
model.set_loss(loss)

if not os.path.exists('./models'):
    os.mkdir('models')
if not os.path.exists('./models/segmentation'):
    os.mkdir('models/segmentation')

if not RETRAIN:
    model.restore()

# Train it and evaluate performance on the test set.
if RETRAIN:
    print("About to fit model for 50 epochs")