Skip to content

Instantly share code, notes, and snippets.

@albertz
Created February 7, 2022 13:55
Show Gist options
  • Save albertz/524c7dc3bd6e962a8a3bfcd3e365adef to your computer and use it in GitHub Desktop.
Save albertz/524c7dc3bd6e962a8a3bfcd3e365adef to your computer and use it in GitHub Desktop.
from returnn.tf.util.data import Dim, batch_dim, single_step_dim, SpatialDim, FeatureDim
use_tensorflow = True
behavior_version = 12
extern_data_data_dim_tags_1_time_dim = SpatialDim('time')
extern_data_data_dim_tags_2_input_dim = FeatureDim('input', 13)
network_linear_subnetwork_random_shape_1_linear_out_dim = FeatureDim('linear-out', 13)
extern_data = {
'data': {
'dim_tags': (
batch_dim,
extern_data_data_dim_tags_1_time_dim,
extern_data_data_dim_tags_2_input_dim
),
'dtype': 'float32',
'available_for_inference': True
}
}
network = {
'linear': {
'class': 'subnetwork',
'from': [],
'subnetwork': {
'random': {
'class': 'random',
'shape': (
extern_data_data_dim_tags_2_input_dim,
network_linear_subnetwork_random_shape_1_linear_out_dim
),
'distribution': 'uniform',
'minval': -0.4803844614152614,
'maxval': 0.4803844614152614,
'dtype': 'float32',
'static': True,
'out_shape': {extern_data_data_dim_tags_2_input_dim, network_linear_subnetwork_random_shape_1_linear_out_dim}
},
'dot': {
'class': 'dot',
'from': ['base:data:data', 'weight'],
'reduce': extern_data_data_dim_tags_2_input_dim,
'out_shape': {batch_dim, extern_data_data_dim_tags_1_time_dim, network_linear_subnetwork_random_shape_1_linear_out_dim}
},
'add': {
'class': 'combine',
'from': ['dot', 'bias'],
'kind': 'add',
'out_shape': {batch_dim, extern_data_data_dim_tags_1_time_dim, network_linear_subnetwork_random_shape_1_linear_out_dim}
},
'output': {
'class': 'copy',
'from': 'add',
'out_shape': {batch_dim, extern_data_data_dim_tags_1_time_dim, network_linear_subnetwork_random_shape_1_linear_out_dim}
},
'weight': {
'class': 'variable',
'shape': [
extern_data_data_dim_tags_2_input_dim,
network_linear_subnetwork_random_shape_1_linear_out_dim
],
'param_name': 'param',
'init_by_layer': 'random'
},
'bias': {
'class': 'variable',
'shape': [
network_linear_subnetwork_random_shape_1_linear_out_dim
],
'param_name': 'param',
'init': 0.0
}
},
'out_shape': {batch_dim, extern_data_data_dim_tags_1_time_dim, network_linear_subnetwork_random_shape_1_linear_out_dim}
},
'output': {
'class': 'copy',
'from': 'linear',
'out_shape': {batch_dim, extern_data_data_dim_tags_1_time_dim, network_linear_subnetwork_random_shape_1_linear_out_dim}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment