예제 #1
0
from ...neuromancer.graphutils import TaggedShape


logger = logging.getLogger('elektronn2log')


__path__ = os.path.dirname(os.path.realpath(__file__))

pydot_imported = False
try:
    # pydot2 supports py3
    import pydotplus as pd


    if pd.find_graphviz():
        pydot_imported = True
except ImportError:
    try:
        # fall back on pydot if necessary
        import pydot as pd


        if pd.find_graphviz():
            pydot_imported = True
    except ImportError:
        pass  # tests should not fail on optional dependency

if not pydot_imported:
    logger.warning('Failed to import pydot/pydotplus. You must install '
                   'graphviz and either pydot or pydotplus for '
예제 #2
0
    """
    Margin loss for Eq.(4). When y_true[i, :] contains not just one `1`, this loss should work too. Not test it.
    :param y_true: [None, n_classes]
    :param y_pred: [None, num_capsule]
    :return: a scalar loss value.
    """
    L = y_true * K.square(K.maximum(0., 0.9 - y_pred)) + \
        0.5 * (1 - y_true) * K.square(K.maximum(0., y_pred - 0.1))

    return K.mean(K.sum(L, 1))

# %%
# define model
model = CapsNet(input_shape=[28, 28, 1],
                n_class=10,
                num_routing=3)
model.summary()
try:
    plot_model(model, to_file='model.png', show_shapes=True)
except Exception as e:
    print("heheheheheheh")
    print('No fancy plot {}'.format(e))

import pydotplus as pydot
pydot.Dot.create(pydot.Dot())
pydot.Dot.create(pydot.Dot())
pydot.find_graphviz()

# import pydot_ng as pydot
# pydot and pydot.find_graphviz()
예제 #3
0
import pydotplus
import unittest


PY3 = not sys.version_info < (3, 0, 0)

if PY3:
    NULL_SEP = b''
    xrange = range
else:
    NULL_SEP = ''
    bytes = str


DOT_BINARY_PATH = pydotplus.find_graphviz()['dot']
TEST_DIR = './'
REGRESSION_TESTS_DIR = os.path.join(TEST_DIR, 'graphs')
MY_REGRESSION_TESTS_DIR = os.path.join(TEST_DIR, 'my_tests')


class TestGraphAPI(unittest.TestCase):

    def setUp(self):

        self._reset_graphs()

    def _reset_graphs(self):

        self.graph_directed = pydotplus.Graph(
            'testgraph', graph_type='digraph'
예제 #4
0
rs = np.argmax(tmp)
print(rs)

# In[89]:

tmp

# # model graph

# In[90]:

import pydotplus

# In[91]:

pydotplus.find_graphviz()

# In[92]:

from IPython.display import SVG
from tensorflow.python.keras.utils.vis_utils import model_to_dot

get_ipython().run_line_magic('matplotlib', 'inline')

# In[93]:

import matplotlib.pyplot as plt
get_ipython().system('pip install graphviz')

# In[95]:
예제 #5
0
import subprocess
import sys

import pydotplus
import unittest

PY3 = not sys.version_info < (3, 0, 0)

if PY3:
    NULL_SEP = b''
    xrange = range
else:
    NULL_SEP = ''
    bytes = str

DOT_BINARY_PATH = pydotplus.find_graphviz()['dot']
TEST_DIR = './'
REGRESSION_TESTS_DIR = os.path.join(TEST_DIR, 'graphs')
MY_REGRESSION_TESTS_DIR = os.path.join(TEST_DIR, 'my_tests')


class TestGraphAPI(unittest.TestCase):
    def setUp(self):

        self._reset_graphs()

    def _reset_graphs(self):

        self.graph_directed = pydotplus.Graph('testgraph',
                                              graph_type='digraph')