f02b56207713275c749ff7c0d337c49bd3dffe53,examples/simple_but_ugly/tf_models.py,MyModel,_build,#MyModel#,16

Before Change


    An example of a tf model class 
    def _build(self, *args, **kwargs):
        images_shape = self.get_from_config("images_shape", (0, 3))
        num_features =  images_shape[-1]
        num_classes = self.get_from_config("num_classes", 3)

        x = tf.placeholder("float", [None, num_features], name="x")
        y = tf.placeholder("int32",[None], name="y")
        y_oe = tf.one_hot(y, num_classes, name="targets")

        w = tf.Variable(tf.zeros([num_features, num_classes]))
        b = tf.Variable(tf.zeros([num_classes]))

        y_ = tf.nn.softmax(tf.matmul(x, w) + b, name="predictions")

        // Define a cost function
        //tf.losses.add_loss(tf.losses.softmax_cross_entropy(y_oe, y_))
        loss = tf.losses.softmax_cross_entropy(y_oe, y_)

After Change


class MyModel(TFModel):
    An example of a tf model class 
    def _build(self, *args, **kwargs):
        images_shape = self.get_from_config("images_shape", (12, 12, 1))
        num_classes = self.get_from_config("num_classes", 3)

        x = tf.placeholder("float", [None] + list(images_shape), name="x")
        y = tf.placeholder("int32",[None], name="y")
        y_oe = tf.one_hot(y, num_classes, name="targets")

        c = conv2d_block(x, 32, 3, conv=dict(kernel_initializer=tf.contrib.layers.xavier_initializer()), max_pooling=dict(strides=4))
        f = flatten(c)
        f = tf.layers.dense(f, num_classes)
        y_ = tf.identity(f, name="predictions")

        // Define a cost function
        //tf.losses.add_loss(tf.losses.softmax_cross_entropy(y_oe, y_))
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 6

Instances


Project Name: analysiscenter/batchflow
Commit Name: f02b56207713275c749ff7c0d337c49bd3dffe53
Time: 2017-10-24
Author: rhudor@gmail.com
File Name: examples/simple_but_ugly/tf_models.py
Class Name: MyModel
Method Name: _build


Project Name: osmr/imgclsmob
Commit Name: 8cc023c568f2cdcdf5c34c5fa1b76090073bca73
Time: 2018-12-04
Author: osemery@gmail.com
File Name: gluon/gluoncv2/models/resattnet.py
Class Name:
Method Name: _test


Project Name: chainer/chainerrl
Commit Name: ad60498885593181f25f02cf01a72ef8f3f18167
Time: 2016-06-03
Author: muupan@gmail.com
File Name: dqn.py
Class Name: DQN
Method Name: _compute_loss