Closed 300LiterPropofol closed 7 months ago
TypeError: pad() missing 1 required positional argument: 'mode'
seems to be a persisting issue across different examples, the same environment cannot run the anomaly_detection.py example in /example folder either,
C:\ProgramData\anaconda3\envs\mxnet_pure\lib\site-packages\gluonts\dataset\jsonl.py:74: FutureWarning: Conversion of the second argument of issubdtype from `int` to `np.signedinteger` is deprecated. In future, it will be treated as `np.int32 == np.dtype(int).type`.
if np.issubdtype(arg.dtype, int):
0%| | 0/100 [00:00<?, ?it/s]
Traceback (most recent call last):
File "anomaly_detection.py", line 48, in <module>
train_output = estimator.train_model(dataset.train)
File "C:\ProgramData\anaconda3\envs\mxnet_pure\lib\site-packages\gluonts\mx\model\estimator.py", line 219, in train_model
validation_iter=validation_data_loader,
File "C:\ProgramData\anaconda3\envs\mxnet_pure\lib\site-packages\gluonts\mx\trainer\_base.py", line 423, in __call__
num_batches_to_use=self.num_batches_per_epoch,
File "C:\ProgramData\anaconda3\envs\mxnet_pure\lib\site-packages\gluonts\mx\trainer\_base.py", line 275, in loop
for batch_no, batch in enumerate(it, start=1):
File "C:\ProgramData\anaconda3\envs\mxnet_pure\lib\site-packages\tqdm\std.py", line 1182, in __iter__
for obj in iterable:
File "C:\ProgramData\anaconda3\envs\mxnet_pure\lib\site-packages\gluonts\itertools.py", line 420, in __iter__
yield from itertools.islice(self.iterable, self.length)
File "C:\ProgramData\anaconda3\envs\mxnet_pure\lib\site-packages\gluonts\transform\_base.py", line 112, in __iter__
self.base_dataset, is_train=self.is_train
File "C:\ProgramData\anaconda3\envs\mxnet_pure\lib\site-packages\gluonts\transform\_base.py", line 132, in __call__
for data_entry in data_it:
File "C:\ProgramData\anaconda3\envs\mxnet_pure\lib\site-packages\gluonts\dataset\loader.py", line 50, in __call__
yield from batcher(data, self.batch_size)
File "C:\ProgramData\anaconda3\envs\mxnet_pure\lib\site-packages\gluonts\itertools.py", line 131, in get_batch
return list(itertools.islice(it, batch_size))
File "C:\ProgramData\anaconda3\envs\mxnet_pure\lib\site-packages\gluonts\transform\_base.py", line 132, in __call__
for data_entry in data_it:
File "C:\ProgramData\anaconda3\envs\mxnet_pure\lib\site-packages\gluonts\transform\_base.py", line 188, in __call__
for result in self.flatmap_transform(data_entry.copy(), is_train):
File "C:\ProgramData\anaconda3\envs\mxnet_pure\lib\site-packages\gluonts\transform\split.py", line 161, in flatmap_transform
yield self._split_instance(entry, idx)
File "C:\ProgramData\anaconda3\envs\mxnet_pure\lib\site-packages\gluonts\transform\split.py", line 134, in _split_instance
past_piece, future_piece = self._split_array(entry[ts_field], idx)
File "C:\ProgramData\anaconda3\envs\mxnet_pure\lib\site-packages\gluonts\transform\split.py", line 118, in _split_array
value=self.dummy_value,
File "C:\ProgramData\anaconda3\envs\mxnet_pure\lib\site-packages\gluonts\zebras\_util.py", line 50, in pad_axis
return np.pad(a, pad_width, constant_values=value)
TypeError: pad() missing 1 required positional argument: 'mode'
Anaconda seems to not work, I managed to bypass this by using docker. This is my requirements.txt
numpy==1.23.5
matplotlib==3.8.2
gluonts==0.14.3
mxnet==1.6.0
orjson==3.9.7
my Dockerfile
# Use an official Python runtime as a parent image
FROM python:3.9.18-bullseye
# Update and install required dependencies
RUN apt-get update && \
apt-get upgrade -y && \
apt-get install -y bash libstdc++6 libgomp1 build-essential
# Install Fortran compiler
RUN apt-get install -y gfortran
# Install musl
RUN apt-get install -y musl
# Set the working directory to /app
WORKDIR /app
# Install any needed packages specified in requirements.txt
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
# Copy the current directory contents into the container at /app
COPY . .
# Make port 3000 available to the world outside this container
EXPOSE 3000
# Run app.py when the container launches
CMD ["python3", "app.py"]
my docker-compose.yml
version: '3'
services:
app:
container_name: app
build:
context: .
ports:
- "3000:3000"
command: [ "python3", "app.py" ]
networks:
- data-stack
volumes:
- .:/app/
networks:
# External network
data-stack:
external: true
since docker does not go well with interactive GUI plotting, I also changed all plt.show() into
# Save the figure to a file
plt.savefig("plot2.png")
plt.close()
Now I can run the example!
For anyone who has same issue, try the exact version above in docker
Description
The stable documentation states a SimpleFeedForwardEstimator as an example, (https://ts.gluon.ai/stable/tutorials/forecasting/extended_tutorial.html#Configuring-an-estimator) However the example can not be executed, python reports an error during execution.
To Reproduce
conda create --name mxnet_pure python=3.7
pip install "gluonts[mxnet]"
python, the same code as in the documentation, but since mxnet cannot work with jupyter notebook as reported here (https://github.com/awslabs/gluonts/issues/3102), the example code is copied inside a .py file and executed from Anaconda Prompt
Error message or code output
Environment
The environment only has the below packages installed