You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 17, 2023. It is now read-only.
Hi, everyone, I am suya, a beginner using mxnet.
These days, when I built the Deepstate and Seq2Seq model, there were bugs that I really cannot solve. I tried many ways but couldn't solve it, please help!
This is my code:
weeks =[1424-7*i for i in range(15)]
iris = ['/content/IRI_DataSet/iri{}.csv'.format(i+1) for i in range(15)]
length = 55
data = []
iri_category = []
for file_path, w in zip(iris, weeks):
unit_columns = ['unit.' + str(i) for i in range(w, w+length)]
price_columns = ['price.' + str(i) for i in range(w, w+length)]
holiday_columns = ['holiday.' + str(i) for i in range(w, w+length)]
d_columns = ['D.' + str(i) for i in range(w, w+length)]
f_columns = ['F.' + str(i) for i in range(w, w+length)]
d = pd.read_csv(file_path)
U = d[unit_columns].values.astype(np.float32)
P = d[price_columns].values.astype(np.float32)
D = d[d_columns].values.astype(np.float32)
F = d[f_columns].values.astype(np.float32)
H = d[holiday_columns].values.astype(np.float32)
iri_category.append(d['unit.cate'].values)
combined = np.concatenate((U, P, D, F, H), axis=1).reshape(-1, 5, length)
data.append(combined)
iri_original = np.concatenate(data, axis=0)
iri_original[iri_original == np.inf] = 0
DeferredInitializationError Traceback (most recent call last)
/usr/local/lib/python3.7/dist-packages/mxnet/gluon/block.py in _build_cache(self, *args)
950 if name in params:
--> 951 params[name].data()
952 except DeferredInitializationError:
ValueError: Deferred initialization failed because shape cannot be inferred. MXNetError: Error in operator deepstatetrainingnetwork13_featureembedder0_squeeze0: [10:43:29] ../src/operator/tensor/./matrix_op-inl.h:2365: Check failed: dshape[axes[i]] == 1 (120138 vs. 1) : cannot select an axis to squeeze out which has size=120138 not equal to one
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi, everyone, I am suya, a beginner using mxnet.
These days, when I built the Deepstate and Seq2Seq model, there were bugs that I really cannot solve. I tried many ways but couldn't solve it, please help!
This is my code:
weeks =[1424-7*i for i in range(15)]
iris = ['/content/IRI_DataSet/iri{}.csv'.format(i+1) for i in range(15)]
length = 55
data = []
iri_category = []
for file_path, w in zip(iris, weeks):
unit_columns = ['unit.' + str(i) for i in range(w, w+length)]
price_columns = ['price.' + str(i) for i in range(w, w+length)]
holiday_columns = ['holiday.' + str(i) for i in range(w, w+length)]
d_columns = ['D.' + str(i) for i in range(w, w+length)]
f_columns = ['F.' + str(i) for i in range(w, w+length)]
d = pd.read_csv(file_path)
U = d[unit_columns].values.astype(np.float32)
P = d[price_columns].values.astype(np.float32)
D = d[d_columns].values.astype(np.float32)
F = d[f_columns].values.astype(np.float32)
H = d[holiday_columns].values.astype(np.float32)
iri_category.append(d['unit.cate'].values)
combined = np.concatenate((U, P, D, F, H), axis=1).reshape(-1, 5, length)
data.append(combined)
iri_original = np.concatenate(data, axis=0)
iri_original[iri_original == np.inf] = 0
here, iri_original.shape = (120138, 5, 55)
then:
feat_static_cat = np.hstack(iri_category)
feat_static_cat = LabelEncoder().fit_transform(feat_static_cat)
feat_static_cat.reshape(len(feat_static_cat))
train_ds = ListDataset(
[{'target': iri_original[i, 0, :-prediction_length],
'feat_dynamic_real': iri_original[i, 1:2, :-prediction_length],
'feat_dynamic_cat': iri_original[i, 2:, :-prediction_length],
'feat_static_cat': feat_static_cat,
'start': start} for i in range(len(iri_original))],
freq=freq)
test_ds = ListDataset(
[{'target': iri_original[i, 0, :],
'feat_dynamic_real': iri_original[i, 1:2, :],
'feat_dynamic_cat': iri_original[i, 2:, :],
'feat_static_cat': feat_static_cat,
'start': start} for i in range(len(iri_original))],
freq=freq)
then build models:
estimator = DeepStateEstimator(
freq = freq,
prediction_length = prediction_length,
cardinality = [6],
embedding_dimension = [10],
num_layers = 1,
num_cells = 80,
#quantiles = [0.5],
trainer = Trainer(
epochs=100,
learning_rate=1e-4,
minimum_learning_rate=1e-10,
num_batches_per_epoch=32),
num_parallel_samples = 100,
#batch_size = 32,
use_feat_dynamic_real = True,
use_feat_static_cat = True,
)
and
estimator = Seq2SeqEstimator(
freq = freq,
prediction_length = prediction_length,
cardinality = [2],
embedding_dimension = 5,
encoder = Seq2SeqEncoder("lstm"),
decoder_mlp_layer = [1],
decoder_mlp_static_dim = 16,
scaler = NOPScaler(),
context_length = 14,
#quantiles = [0.5],
trainer = Trainer(epochs = 10, num_batches_per_epoch= 32, learning_rate=0.001),
num_parallel_samples = 100,
batch_size = 32
)
However, there were problems:
0%| | 0/32 [00:00<?, ?it/s]infer_shape error. Arguments:
data0: (32, 120138)
data1: (32, 208, 1)
data2: (32, 208, 2)
data3: (32, 208, 4)
data4: (32, 208, 1)
DeferredInitializationError Traceback (most recent call last)
/usr/local/lib/python3.7/dist-packages/mxnet/gluon/block.py in _build_cache(self, *args)
950 if name in params:
--> 951 params[name].data()
952 except DeferredInitializationError:
ValueError: Deferred initialization failed because shape cannot be inferred. MXNetError: Error in operator deepstatetrainingnetwork13_featureembedder0_squeeze0: [10:43:29] ../src/operator/tensor/./matrix_op-inl.h:2365: Check failed: dshape[axes[i]] == 1 (120138 vs. 1) : cannot select an axis to squeeze out which has size=120138 not equal to one
0%| | 0/32 [00:00<?, ?it/s]
NotImplementedError Traceback (most recent call last)
in ()
----> 1 predictor = estimator.train(train_ds)
13 frames
/usr/local/lib/python3.7/dist-packages/gluonts/mx/block/encoder.py in hybrid_forward(self, F, target, static_features, dynamic_features)
63 shape (batch_size, sequence_length, num_feat_dynamic)
64 """
---> 65 raise NotImplementedError
66
67 def _assemble_inputs(
NotImplementedError:
Beta Was this translation helpful? Give feedback.
All reactions