# Path: moonlight/glyphs/neural.py
# NUM_GLYPHS = len(musicscore_pb2.Glyph.Type.values()) - 1
# class NeuralNetworkGlyphClassifier(object):
# class BaseLayer(object):
# class InputConvLayer(BaseLayer):
# class HiddenLayer(BaseLayer):
# class ReconstructionLayer(BaseLayer):
# class PredictionLayer(BaseLayer):
#   def __init__(self,
#                input_placeholder,
#                hidden_layer,
#                reconstruction_layer=None,
#                autoencoder_vars=None,
#                labels_placeholder=None,
#                prediction_layer=None,
#                prediction_vars=None):
#   def get_autoencoder_initializers(self):
#   def get_classifier_initializers(self):
#   def semi_supervised_model(batch_size,
#                             target_height,
#                             input_placeholder=None,
#                             labels_placeholder=None):
#   def __init__(self, filter_size, n_in, n_out, name):
#   def get(self):
#   def __init__(self, image, n_hidden, activation=tf.nn.sigmoid, name="input"):
#   def __init__(self,
#                layer_in,
#                filter_size,
#                n_out,
#                activation=tf.nn.sigmoid,
#                name="hidden"):
#   def __init__(self,
#                layer_in,
#                filter_size,
#                out_height,
#                activation=tf.nn.sigmoid,
#                name="reconstruction"):
#   def __init__(self, layer_in, name="prediction"):


import numpy as np
import tensorflow as tf
from moonlight.glyphs import neural
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Tests for the neural network glyph classifier."""

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function



NUM_STAFFLINES = 5
TARGET_HEIGHT = 15
IMAGE_WIDTH = 100


class NeuralNetworkGlyphClassifierTest(tf.test.TestCase):

  def testSemiSupervisedClassifier(self):
    # Ensure that the losses can be evaluated without error.
    stafflines = tf.random_uniform((NUM_STAFFLINES, TARGET_HEIGHT, IMAGE_WIDTH))
    # Use every single glyph once except for NONE (0).
    labels_single_batch = np.concatenate([
        np.arange(neural.NUM_GLYPHS),
        np.zeros(IMAGE_WIDTH - neural.NUM_GLYPHS)
    ]).astype(np.int32)
    labels = np.repeat(labels_single_batch[None, :], NUM_STAFFLINES, axis=0)

# Path: moonlight/glyphs/neural.py
# NUM_GLYPHS = len(musicscore_pb2.Glyph.Type.values()) - 1
# class NeuralNetworkGlyphClassifier(object):
# class BaseLayer(object):
# class InputConvLayer(BaseLayer):
# class HiddenLayer(BaseLayer):
# class ReconstructionLayer(BaseLayer):
# class PredictionLayer(BaseLayer):
#   def __init__(self,
#                input_placeholder,
#                hidden_layer,
#                reconstruction_layer=None,
#                autoencoder_vars=None,
#                labels_placeholder=None,
#                prediction_layer=None,
#                prediction_vars=None):
#   def get_autoencoder_initializers(self):
#   def get_classifier_initializers(self):
#   def semi_supervised_model(batch_size,
#                             target_height,
#                             input_placeholder=None,
#                             labels_placeholder=None):
#   def __init__(self, filter_size, n_in, n_out, name):
#   def get(self):
#   def __init__(self, image, n_hidden, activation=tf.nn.sigmoid, name="input"):
#   def __init__(self,
#                layer_in,
#                filter_size,
#                n_out,
#                activation=tf.nn.sigmoid,
#                name="hidden"):
#   def __init__(self,
#                layer_in,
#                filter_size,
#                out_height,
#                activation=tf.nn.sigmoid,
#                name="reconstruction"):
#   def __init__(self, layer_in, name="prediction"):


# Path: moonlight/glyphs/neural_test.py
import numpy as np
import tensorflow as tf
from moonlight.glyphs import neural

#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Tests for the neural network glyph classifier."""

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function



NUM_STAFFLINES = 5
TARGET_HEIGHT = 15
IMAGE_WIDTH = 100


class NeuralNetworkGlyphClassifierTest(tf.test.TestCase):

  def testSemiSupervisedClassifier(self):
    # Ensure that the losses can be evaluated without error.
    stafflines = tf.random_uniform((NUM_STAFFLINES, TARGET_HEIGHT, IMAGE_WIDTH))
    # Use every single glyph once except for NONE (0).
    labels_single_batch = np.concatenate([
        np.arange(neural.NUM_GLYPHS),
        np.zeros(IMAGE_WIDTH - neural.NUM_GLYPHS)
    ]).astype(np.int32)
    labels = np.repeat(labels_single_batch[None, :], NUM_STAFFLINES, axis=0)

    classifier = neural.NeuralNetworkGlyphClassifier.semi_supervised_model(