Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_create_one_vnode(self):
from deephyper.search.nas.model.space.struct import AutoOutputStructure
struct = AutoOutputStructure((5, ), (1, ))
from deephyper.search.nas.model.space.node import VariableNode
vnode = VariableNode()
struct.connect(struct.input_nodes[0], vnode)
from deephyper.search.nas.model.space.op.op1d import Dense
vnode.add_op(Dense(10))
struct.set_ops([0])
falias = 'test_direct_structure'
struct.draw_graphviz(f'{falias}.dot')
model = struct.create_model()
from tensorflow.keras.utils import plot_model
plot_model(model, to_file=f'{falias}.png', show_shapes=True)
def test_create_one_vnode(self):
from deephyper.search.nas.model.space.struct import DirectStructure
struct = DirectStructure((5, ), (1, ))
from deephyper.search.nas.model.space.node import VariableNode
vnode = VariableNode()
struct.connect(struct.input_nodes[0], vnode)
from deephyper.search.nas.model.space.op.op1d import Dense
vnode.add_op(Dense(1))
struct.set_ops([0])
falias = 'test_direct_structure'
struct.draw_graphviz(f'{falias}.dot')
model = struct.create_model()
from tensorflow.keras.utils import plot_model
plot_model(model, to_file=f'{falias}.png', show_shapes=True)
for n in filter(lambda n: isinstance(n, VariableNode), self.nodes):
if n.num_ops != 0:
def create_structure(input_shape=(2,), output_shape=(1,), **kwargs):
struct = AutoOutputStructure(input_shape, output_shape, regression=True)
vnode1 = VariableNode()
for i in range(1, 11):
vnode1.add_op(Dense(i, tf.nn.relu))
struct.connect(struct.input_nodes[0], vnode1)
return struct
return filter(lambda n: isinstance(n, VariableNode), self.nodes)
for i in range(16, 129, 16):
vnode.add_op(Dense(i, tf.nn.relu))
struct.connect(prev_node, vnode)
prev_node = vnode
out1 = ConstantNode(op=Dense(1, name="output_0"))
struct.connect(prev_node, out1)
# auto-encoder
# units = [128, 64, 32, 16, 8, 16, 32, 64, 128]
units = [32, 16, 32]
prev_node = inp
d = 1
for i in range(len(units)):
vnode = VariableNode()
# vnode.add_op(Identity)
if d == 1 and units[i] < units[i + 1]:
d = -1
# print(min(1, units[i]), ' - ', max(1, units[i])+1)
for u in range(min(2, units[i], 2), max(2, units[i]) + 1, 2):
vnode.add_op(Dense(u, tf.nn.relu))
latente_space = vnode
else:
# print(min(units[i], units[i+d]), ' - ', max(units[i], units[i+d])+1)
for u in range(
min(units[i], units[i + d]), max(units[i], units[i + d]) + 1, 2
):
vnode.add_op(Dense(u, tf.nn.relu))
struct.connect(prev_node, vnode)
prev_node = vnode
anchor_points = collections.deque([source], maxlen=3)
for _ in range(num_layers):
vnode = VariableNode()
add_dense_to_(vnode)
arch.connect(prev_input, vnode)
# * Cell output
cell_output = vnode
cmerge = ConstantNode()
cmerge.set_op(AddByProjecting(arch, [cell_output], activation='relu'))
for anchor in anchor_points:
skipco = VariableNode()
skipco.add_op(Tensor([]))
skipco.add_op(Connect(arch, anchor))
arch.connect(skipco, cmerge)
# ! for next iter
prev_input = cmerge
anchor_points.append(prev_input)
return arch
return len(list(filter(lambda n: isinstance(n, VariableNode), self.nodes)))
filter(lambda n: isinstance(n, VariableNode), self.inputs))
variable_ouputs = list(